summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-05-16 12:36:17 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-05-16 12:36:17 +1000
commit2f1b5259188698501dbc8430f63972bf7bc68154 (patch)
tree768571fdc1b9c60001976be817383308c89c9c40 /test
parentdc906c679171950807a47ca9821616548e84a2ff (diff)
parent6ad9b44b27ede70ec723204bd80361d60f448c1a (diff)
downloadscala-2f1b5259188698501dbc8430f63972bf7bc68154.tar.gz
scala-2f1b5259188698501dbc8430f63972bf7bc68154.tar.bz2
scala-2f1b5259188698501dbc8430f63972bf7bc68154.zip
Merge pull request #4497 from retronym/topic/indylambda-diy-boxing
[indylambda] Relieve LambdaMetafactory of boxing duties [ci: last-only]
Diffstat (limited to 'test')
-rw-r--r--test/files/run/function-null-unbox.scala8
-rw-r--r--test/files/run/indylambda-boxing/VC.scala2
-rw-r--r--test/files/run/indylambda-boxing/test.scala29
3 files changed, 39 insertions, 0 deletions
diff --git a/test/files/run/function-null-unbox.scala b/test/files/run/function-null-unbox.scala
new file mode 100644
index 0000000000..6c0369fffd
--- /dev/null
+++ b/test/files/run/function-null-unbox.scala
@@ -0,0 +1,8 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val i2s = (x: Int) => ""
+ assert(i2s.asInstanceOf[AnyRef => String].apply(null) == "")
+ val i2i = (x: Int) => x + 1
+ assert(i2i.asInstanceOf[AnyRef => Int].apply(null) == 1)
+ }
+}
diff --git a/test/files/run/indylambda-boxing/VC.scala b/test/files/run/indylambda-boxing/VC.scala
new file mode 100644
index 0000000000..ef867a3658
--- /dev/null
+++ b/test/files/run/indylambda-boxing/VC.scala
@@ -0,0 +1,2 @@
+
+class VC(private val i: Int) extends AnyVal
diff --git a/test/files/run/indylambda-boxing/test.scala b/test/files/run/indylambda-boxing/test.scala
new file mode 100644
index 0000000000..cc0a460640
--- /dev/null
+++ b/test/files/run/indylambda-boxing/test.scala
@@ -0,0 +1,29 @@
+class Capture
+class Test {
+ def test1 = (i: Int) => ""
+ def test2 = (i: VC) => i
+ def test3 = (i: Int) => i
+
+ def test4 = {val c = new Capture; (i: Int) => {(c, Test.this.toString); 42} }
+ 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)}
+ def test9 = {val c = 42; (s: 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("")
+ }
+}