Skip to content

Commit be61c78

Browse files
committed
Add tests for #499
1 parent 7a8bc79 commit be61c78

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/run/byNameVarargs/i499.scala

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
object Test {
2+
def foo(a: => Any*) = ()
3+
def bar(a: => Any*) = foo(a : _*)
4+
def baz(a: => Seq[Any]) = foo(a : _*)
5+
bar(???, ???)
6+
baz(Seq(???, ???))
7+
baz(Array(???, ???))
8+
9+
def foo1(a => Any, b: => Any*) = ()
10+
foo1(???)
11+
foo1(???, ???, ???)
12+
13+
def assertFails(a => Any) = {
14+
var failed = false
15+
try {
16+
a
17+
} catch {
18+
case e => failed = true
19+
}
20+
assert(failed)
21+
}
22+
23+
def forceLength(b: => Any*) = b.length
24+
assertFails(forceLength(???))
25+
26+
def forceHead(b: => Any*) = b(0)
27+
assertFails(forceHead(1, ???))
28+
}

0 commit comments

Comments
 (0)