Skip to content

Commit 32e6c7d

Browse files
committed
Fix printed type bounds in LambdaTypes
1 parent ef418ac commit 32e6c7d

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -475,34 +475,41 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
475475

476476
def printTargDef(arg: TypeDef, isMember: Boolean = false): Buffer = {
477477
val TypeDef(name, rhs) = arg
478+
def printBounds(bounds: TypeBoundsTree): Buffer = {
479+
val TypeBoundsTree(lo, hi) = bounds
480+
lo match {
481+
case TypeTree.Synthetic() =>
482+
case _ =>
483+
this += " >: "
484+
printTypeTree(lo)
485+
}
486+
hi match {
487+
case TypeTree.Synthetic() => this
488+
case _ =>
489+
this += " <: "
490+
printTypeTree(hi)
491+
}
492+
}
478493
this += name
479494
rhs match {
480-
case TypeBoundsTree(lo, hi) =>
481-
lo match {
482-
case TypeTree.Synthetic() => this
483-
case _ =>
484-
this += " >: "
485-
printTypeTree(lo)
486-
}
487-
hi match {
488-
case TypeTree.Synthetic() => this
489-
case _ =>
490-
this += " <: "
491-
printTypeTree(hi)
492-
}
495+
case rhs @ TypeBoundsTree(lo, hi) => printBounds(rhs)
493496
case rhs @ SyntheticBounds() =>
494497
printTypeOrBound(rhs.tpe)
495498
case rhs @ TypeTree.TypeLambdaTree(tparams, body) =>
499+
def printParam(t: TypeOrBoundsTree): Unit = t match {
500+
case t @ TypeBoundsTree(_, _) => printBounds(t)
501+
case t @ TypeTree() => printTypeTree(t)
502+
}
496503
def printSeparated(list: List[TypeDef]): Unit = list match {
497504
case Nil =>
498505
case x :: Nil =>
499506
val TypeDef(name, trhs) = x
500507
this += name
501-
printTypeOrBoundsTree(trhs)
508+
printParam(trhs)
502509
case x :: xs =>
503510
val TypeDef(name, trhs) = x
504511
this += name
505-
printTypeOrBoundsTree(trhs)
512+
printParam(trhs)
506513
this += ", "
507514
printSeparated(xs)
508515
}

tests/pos/i1181.decompiled

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** Decompiled from out/posTestFromTasty/pos/i1181/Test.class */
22
object Test {
3-
def foo[M[_$1 >: scala.Nothing <: scala.Any]](x: M[scala.Int]): M[scala.Int] = x
4-
type Alias[A >: scala.Nothing <: scala.Any] = scala.Tuple2[A, A]
3+
def foo[M[_$1]](x: M[scala.Int]): M[scala.Int] = x
4+
type Alias[A] = scala.Tuple2[A, A]
55
val x: Test.Alias[scala.Int] = scala.Tuple2.apply[scala.Int, scala.Int](1, 2)
66
Test.foo[Test.Alias](Test.x)
77
Test.foo[[A >: scala.Nothing <: scala.Any] => scala.Tuple2[A, A]](Test.x)

0 commit comments

Comments
 (0)