Skip to content

Commit 6199d07

Browse files
Merge pull request #4701 from dotty-staging/decompile-fix-varargs
Fix printing varargs _*
2 parents 4449c9f + 5c850b5 commit 6199d07

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,15 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
869869
printRefinement(tpe)
870870

871871
case Type.AppliedType(tp, args) =>
872-
printType(tp)
873-
this += "["
874-
printTypesOrBounds(args, ", ")
875-
this += "]"
872+
tp match {
873+
case Type.TypeRef("<repeated>", Types.ScalaPackage()) =>
874+
this += "_*"
875+
case _ =>
876+
printType(tp)
877+
this += "["
878+
printTypesOrBounds(args, ", ")
879+
this += "]"
880+
}
876881

877882
case Type.AnnotatedType(tp, annot) =>
878883
val Annotation(ref, args) = annot

tests/run/t889.decompiled

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** Decompiled from out/runTestFromTasty/run/t889/Test.class */
2+
object Test extends dotty.runtime.LegacyApp() {
3+
val a: collection.immutable.List[java.lang.String] = scala.List.apply[java.lang.String]("a")
4+
Test.a match {
5+
case scala.Seq("a", "b", rest: _*) =>
6+
scala.Predef.println("a, b, ".+(rest))
7+
case scala.Seq(first, rest: _*) =>
8+
scala.Predef.println("first: ".+(first).+(", rest: ").+(rest))
9+
}
10+
}

0 commit comments

Comments
 (0)