summaryrefslogtreecommitdiff
path: root/test/files/run/indylambda-boxing/test.scala
blob: 82f8d2f497868af3feb5783a1c8937de10c2b0bf (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
28
29
30
class Capture
class Test {
  def test1 = (i: Int) => ""
  def test2 = (i: VC) => i
  def test3 = (i: Int) => i // not adapted, specialized

  def test4 = {val c = new Capture; (i: Int) => {(c, Test.this.toString); 42} } // not adapted, specialized
  def test5 = {val c = new Capture; (i: VC) => (c, Test.this.toString) }
  def test6 = {val c = new Capture; (i: Int) => (c, Test.this.toString) }

  def test7 = {val vc = new Capture; (i: Int) => vc }
  def test8 = {val c = 42; (s: String) => (s, c)} // not adapted
  def test9 = {val c = 42; (s: String) => ()}
  def test10 = {(s: List[String]) => ()}
}

object Test {
  def main(args: Array[String]): Unit = {
    val t = new Test
    assert(t.test1.apply(42) == "")
    assert(t.test2.apply(new VC(42)) == new VC(42))
    assert(t.test3.apply(-1) == -1)
    t.test4.apply(0)
    t.test5.apply(new VC(42))
    t.test6.apply(42)
    t.test7.apply(0)
    t.test8.apply("")
    t.test9.apply("")
  }
}