aboutsummaryrefslogtreecommitdiff
path: root/tests/run/t8017
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-05-23 17:58:16 +0200
committerGuillaume Martres <smarter@ubuntu.com>2015-05-23 18:59:54 +0200
commit3fa6782bbe54afeebb7fca229cebff271421f73a (patch)
treedb78538476afa3fed01a7a0395f56cbe873ab3d6 /tests/run/t8017
parente61e59f739d889549993afdd743cbaf71a95c45e (diff)
downloaddotty-3fa6782bbe54afeebb7fca229cebff271421f73a.tar.gz
dotty-3fa6782bbe54afeebb7fca229cebff271421f73a.tar.bz2
dotty-3fa6782bbe54afeebb7fca229cebff271421f73a.zip
Fix bridge creation for value classes
As the comment in the code says: "In general, a bridge is needed when the signature of the closure method after Erasure contains an ErasedValueType but the corresponding type in the functional interface is not an ErasedValueType." So we need to check if _at least one_ of the type needs to be adapted, not if _all of them_ need to, the use of "forall" was an error.
Diffstat (limited to 'tests/run/t8017')
-rw-r--r--tests/run/t8017/value-class-lambda.scala40
-rw-r--r--tests/run/t8017/value-class.scala3
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/run/t8017/value-class-lambda.scala b/tests/run/t8017/value-class-lambda.scala
new file mode 100644
index 000000000..f247e35f6
--- /dev/null
+++ b/tests/run/t8017/value-class-lambda.scala
@@ -0,0 +1,40 @@
+object Test {
+ def testC: Unit = {
+ val f1 = (c: C) => c.value
+ val f2 = (x: Int) => new C(x)
+ val f3 = (c1: C) => (c2: C) => (c1, c2)
+ val r1 = f2(2)
+ val r2 = f2(2)
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == 2)
+ }
+
+ def testD: Unit = {
+ val f1 = (c: D) => c.value
+ val f2 = (x: String) => new D(x)
+ val f3 = (c1: D) => (c2: D) => (c1, c2)
+ val r1 = f2("2")
+ val r2 = f2("2")
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == "2")
+ }
+
+ def testE: Unit = {
+ val f1 = (c: E[Int]) => c.value
+ val f2 = (x: Int) => new E(x)
+ val f3 = (c1: E[Int]) => (c2: E[Int]) => (c1, c2)
+ val r1 = f2(2)
+ val r2 = f2(2)
+ val r3 = f3(r1)(r2)
+ val result = f1(r3._2)
+ assert(result == 2)
+ }
+
+ def main(args: Array[String]): Unit = {
+ testC
+ testD
+ testE
+ }
+}
diff --git a/tests/run/t8017/value-class.scala b/tests/run/t8017/value-class.scala
new file mode 100644
index 000000000..821239305
--- /dev/null
+++ b/tests/run/t8017/value-class.scala
@@ -0,0 +1,3 @@
+class C(val value: Int) extends AnyVal
+class D(val value: String) extends AnyVal
+class E[A](val value: A) extends AnyVal