Skip to content

Commit 4449c9f

Browse files
Merge pull request #4703 from dotty-staging/decompile-fix-empty-varargs
Do not print trailing comma for empty var args
2 parents 90904e8 + 0f97884 commit 4449c9f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,13 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
300300
case Term.Select(Term.This(_), "<init>", _) => this += "this" // call to constructor inside a constructor
301301
case _ => printTree(fn)
302302
}
303+
val args1 = args match {
304+
case init :+ Term.Typed(Term.Repeated(Nil), _) => init // drop empty var args at the end
305+
case _ => args
306+
}
307+
303308
this += "("
304-
printTrees(args, ", ")
309+
printTrees(args1, ", ")
305310
this += ")"
306311

307312
case Term.TypeApply(fn, args) =>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** Decompiled from out/posTestFromTasty/pos/simple-repeated-args/Foo.class */
22
class Foo() {
33
scala.List.apply[scala.Any](1, "2", '3')
4+
scala.Array.apply(1)
45
}

tests/pos/simple-repeated-args.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class Foo {
22
List(1, "2", '3')
3+
Array(1)
34
}

0 commit comments

Comments
 (0)