diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-09-09 15:31:21 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-09-09 15:31:21 +0200 |
commit | 2ac6dc03088ecec871838d23aeb688d0e3d4eefb (patch) | |
tree | 9c8d12ccd3c223144f1a504eaa76274a3678fc75 /test/files | |
parent | abd595db299024b76f75da0728ae7ec4fca4bcae (diff) | |
parent | e01b461ad98a7cd6183d222ef91c674306c62ffd (diff) | |
download | scala-2ac6dc03088ecec871838d23aeb688d0e3d4eefb.tar.gz scala-2ac6dc03088ecec871838d23aeb688d0e3d4eefb.tar.bz2 scala-2ac6dc03088ecec871838d23aeb688d0e3d4eefb.zip |
Merge pull request #3938 from gourlaysama/wip/t8764
SI-8764 fix return type of case class productElement under Xexperimental
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t8764.check | 6 | ||||
-rw-r--r-- | test/files/neg/t8764.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t8764.scala | 9 | ||||
-rw-r--r-- | test/files/run/t8764.check | 5 | ||||
-rw-r--r-- | test/files/run/t8764.flags | 1 | ||||
-rw-r--r-- | test/files/run/t8764.scala | 16 |
6 files changed, 38 insertions, 0 deletions
diff --git a/test/files/neg/t8764.check b/test/files/neg/t8764.check new file mode 100644 index 0000000000..6d89ebe106 --- /dev/null +++ b/test/files/neg/t8764.check @@ -0,0 +1,6 @@ +t8764.scala:8: error: type mismatch; + found : AnyVal + required: Double + val d: Double = a.productElement(0) + ^ +one error found diff --git a/test/files/neg/t8764.flags b/test/files/neg/t8764.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/neg/t8764.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/neg/t8764.scala b/test/files/neg/t8764.scala new file mode 100644 index 0000000000..dc5bfb0160 --- /dev/null +++ b/test/files/neg/t8764.scala @@ -0,0 +1,9 @@ +object Main { + + case class IntAndDouble(i: Int, d: Double) + + // a.productElement used to be Int => Double + // now: Int => AnyVal + val a = IntAndDouble(1, 5.0) + val d: Double = a.productElement(0) +} diff --git a/test/files/run/t8764.check b/test/files/run/t8764.check new file mode 100644 index 0000000000..6260069602 --- /dev/null +++ b/test/files/run/t8764.check @@ -0,0 +1,5 @@ +IntOnly: should return an unboxed int +Int: int +IntAndDouble: should just box and return Anyval +Double: class java.lang.Double +Int: class java.lang.Integer diff --git a/test/files/run/t8764.flags b/test/files/run/t8764.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/run/t8764.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/run/t8764.scala b/test/files/run/t8764.scala new file mode 100644 index 0000000000..decc658f6e --- /dev/null +++ b/test/files/run/t8764.scala @@ -0,0 +1,16 @@ +object Test extends App { +case class IntOnly(i: Int, j: Int) + +println("IntOnly: should return an unboxed int") +val a = IntOnly(1, 2) +val i: Int = a.productElement(0) +println(s"Int: ${a.productElement(0).getClass}") + +case class IntAndDouble(i: Int, d: Double) + +println("IntAndDouble: should just box and return Anyval") +val b = IntAndDouble(1, 2.0) +val j: AnyVal = b.productElement(0) +println(s"Double: ${b.productElement(1).getClass}") +println(s"Int: ${b.productElement(0).getClass}") +} |