Skip to content

Commit 5aedeb0

Browse files
committed
Add more tests for repeated args
1 parent 7051a04 commit 5aedeb0

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/pos/repeatedArgs.scala

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
object testRepeated {
2-
def foo = java.lang.System.out.format("%4$2s %3$2s %2$2s %1$2s", "a", "b", "c", "d")
1+
import scala.collection.{immutable, mutable}
2+
import java.nio.file.Paths
3+
4+
class repeatedArgs {
5+
def bar(xs: String*): Int = xs.length
6+
7+
def test(xs: immutable.Seq[String], ys: collection.Seq[String], zs: Array[String]): Unit = {
8+
bar("a", "b", "c")
9+
bar(xs: _*)
10+
bar(ys: _*) // error in 2.13
11+
bar(zs: _*)
12+
13+
Paths.get("Hello", "World")
14+
Paths.get("Hello", xs: _*)
15+
Paths.get("Hello", ys: _*) // error in 2.13
16+
Paths.get("Hello", zs: _*)
17+
18+
val List(_, others: _*) = xs.toList // toList should not be needed, see #4790
19+
val x: collection.Seq[String] = others
20+
// val y: immutable.Seq[String] = others // ok in 2.13
21+
}
322
}

0 commit comments

Comments
 (0)