aboutsummaryrefslogtreecommitdiff
path: root/tests/run/byNameVarargs/i499.scala
blob: e1550b6ec6597d1aa42184a82534076255f97c11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
object Test extends dotty.runtime.LegacyApp{
  def foo(a: => Any*) = ()
  def bar(a: => Any*) = foo(a : _*)
  def baz(a: => Seq[Any]) = foo(a : _*)
  bar(???, ???)
  baz(Seq(???, ???))

  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, ???))
}