Skip to content

Commit c5d3b67

Browse files
committed
Fix reflect SuperType.supertpe and printing super types and type lambdas
1 parent ba481c6 commit c5d3b67

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
18611861
given SuperTypeMethods: SuperTypeMethods with
18621862
extension (self: SuperType)
18631863
def thistpe: TypeRepr = self.thistpe
1864-
def supertpe: TypeRepr = self.thistpe
1864+
def supertpe: TypeRepr = self.supertpe
18651865
end extension
18661866
end SuperTypeMethods
18671867

compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,12 +1189,12 @@ object SourceCode {
11891189
}
11901190

11911191
case SuperType(thistpe, supertpe) =>
1192-
printType(supertpe)
1192+
printType(thistpe)
11931193
this += highlightTypeDef(".super")
11941194

11951195
case TypeLambda(paramNames, tparams, body) =>
11961196
inSquare(printMethodicTypeParams(paramNames, tparams))
1197-
this += highlightTypeDef(" => ")
1197+
this += highlightTypeDef(" =>> ")
11981198
printType(body)
11991199

12001200
case ParamRef(lambda, idx) =>

tests/pos-macros/hk-quoted-type-patterns/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ private def impl(x: Expr[Any])(using Quotes): Expr[Unit] = {
55
case '{ foo[x] } =>
66
assert(Type.show[x] == "scala.Int", Type.show[x])
77
case '{ type f[X]; foo[`f`] } =>
8-
assert(Type.show[f] == "[A >: scala.Nothing <: scala.Any] => scala.collection.immutable.List[A]", Type.show[f])
8+
assert(Type.show[f] == "[A >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.List[A]", Type.show[f])
99
case '{ type f <: AnyKind; foo[`f`] } =>
10-
assert(Type.show[f] == "[K >: scala.Nothing <: scala.Any, V >: scala.Nothing <: scala.Any] => scala.collection.immutable.Map[K, V]", Type.show[f])
10+
assert(Type.show[f] == "[K >: scala.Nothing <: scala.Any, V >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.Map[K, V]", Type.show[f])
1111
case x => throw MatchError(x.show)
1212
'{}
1313
}

tests/run-macros/i10863.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[A >: scala.Nothing <: scala.Any] => scala.collection.immutable.List[A]
1+
[A >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.List[A]

tests/run-macros/i8514b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
B
2-
A[[T >: scala.Nothing <: scala.Any] => P[T], scala.Predef.String]
2+
A[[T >: scala.Nothing <: scala.Any] =>> P[T], scala.Predef.String]
33
java.lang.Object
44
scala.Matchable
55
scala.Any
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Functor[scala.collection.immutable.List]
2-
Unapply[[F >: scala.Nothing <: [_$9 >: scala.Nothing <: scala.Any] => scala.Any] => Functor[F], Wrap[scala.Int]]
3-
Unapply[[F >: scala.Nothing <: [_$9 >: scala.Nothing <: scala.Any] => scala.Any] => Functor[F], Wrap[Dummy]]
2+
Unapply[[F >: scala.Nothing <: [_$9 >: scala.Nothing <: scala.Any] =>> scala.Any] =>> Functor[F], Wrap[scala.Int]]
3+
Unapply[[F >: scala.Nothing <: [_$9 >: scala.Nothing <: scala.Any] =>> scala.Any] =>> Functor[F], Wrap[Dummy]]
44
Functor[scala.Option]

tests/run-macros/type-show/Test_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
assert(show[Int => Int] == "scala.Function1[scala.Int, scala.Int]")
1010
assert(show[(Int, String)] == "scala.Tuple2[scala.Int, scala.Predef.String]")
1111
assert(show[[X] =>> X match { case Int => Int }] ==
12-
"""[X >: scala.Nothing <: scala.Any] => X match {
12+
"""[X >: scala.Nothing <: scala.Any] =>> X match {
1313
| case scala.Int => scala.Int
1414
|}""".stripMargin)
1515
assert(showStructure[[X] =>> X match { case Int => Int }] == """TypeLambda(List(X), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Nothing"), TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"))), MatchType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"), ParamRef(binder, 0), List(MatchCase(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int")))))""")

tests/run-staging/i5965.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ List(1, 2, 3)
1111
}
1212
Some(4)
1313
{
14-
val y: [V >: scala.Nothing <: scala.Any] => scala.collection.immutable.Map[scala.Int, V][scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1))
14+
val y: [V >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.Map[scala.Int, V][scala.Int] = scala.Predef.Map.apply[scala.Int, scala.Int](scala.Predef.ArrowAssoc[scala.Int](4).->[scala.Int](1))
1515

1616
(y: scala.collection.immutable.Map[scala.Int, scala.Int])
1717
}

0 commit comments

Comments
 (0)