Skip to content

Commit dab28e8

Browse files
committed
Fix printed type bounds in LambdaTypes
1 parent 0e13b0e commit dab28e8

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
@@ -500,34 +500,41 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
500500

501501
def printTargDef(arg: TypeDef, isMember: Boolean = false): Buffer = {
502502
val TypeDef(name, rhs) = arg
503+
def printBounds(bounds: TypeBoundsTree): Buffer = {
504+
val TypeBoundsTree(lo, hi) = bounds
505+
lo match {
506+
case TypeTree.Synthetic() =>
507+
case _ =>
508+
this += " >: "
509+
printTypeTree(lo)
510+
}
511+
hi match {
512+
case TypeTree.Synthetic() => this
513+
case _ =>
514+
this += " <: "
515+
printTypeTree(hi)
516+
}
517+
}
503518
this += name
504519
rhs match {
505-
case TypeBoundsTree(lo, hi) =>
506-
lo match {
507-
case TypeTree.Synthetic() => this
508-
case _ =>
509-
this += " >: "
510-
printTypeTree(lo)
511-
}
512-
hi match {
513-
case TypeTree.Synthetic() => this
514-
case _ =>
515-
this += " <: "
516-
printTypeTree(hi)
517-
}
520+
case rhs @ TypeBoundsTree(lo, hi) => printBounds(rhs)
518521
case rhs @ SyntheticBounds() =>
519522
printTypeOrBound(rhs.tpe)
520523
case rhs @ TypeTree.TypeLambdaTree(tparams, body) =>
524+
def printParam(t: TypeOrBoundsTree): Unit = t match {
525+
case t @ TypeBoundsTree(_, _) => printBounds(t)
526+
case t @ TypeTree() => printTypeTree(t)
527+
}
521528
def printSeparated(list: List[TypeDef]): Unit = list match {
522529
case Nil =>
523530
case x :: Nil =>
524531
val TypeDef(name, trhs) = x
525532
this += name
526-
printTypeOrBoundsTree(trhs)
533+
printParam(trhs)
527534
case x :: xs =>
528535
val TypeDef(name, trhs) = x
529536
this += name
530-
printTypeOrBoundsTree(trhs)
537+
printParam(trhs)
531538
this += ", "
532539
printSeparated(xs)
533540
}

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)