From be61c7813fbf7cab90b5d70ef6e506e296c510dc Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Thu, 30 Apr 2015 16:43:40 +0200 Subject: Add tests for #499 --- tests/run/byNameVarargs/i499.scala | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/run/byNameVarargs/i499.scala (limited to 'tests') diff --git a/tests/run/byNameVarargs/i499.scala b/tests/run/byNameVarargs/i499.scala new file mode 100644 index 000000000..be40ead50 --- /dev/null +++ b/tests/run/byNameVarargs/i499.scala @@ -0,0 +1,28 @@ +object Test { + def foo(a: => Any*) = () + def bar(a: => Any*) = foo(a : _*) + def baz(a: => Seq[Any]) = foo(a : _*) + bar(???, ???) + baz(Seq(???, ???)) + baz(Array(???, ???)) + + def foo1(a => Any, b: => Any*) = () + foo1(???) + foo1(???, ???, ???) + + def assertFails(a => Any) = { + var failed = false + try { + a + } catch { + case e => failed = true + } + assert(failed) + } + + def forceLength(b: => Any*) = b.length + assertFails(forceLength(???)) + + def forceHead(b: => Any*) = b(0) + assertFails(forceHead(1, ???)) +} -- cgit v1.2.3