From e01b461ad98a7cd6183d222ef91c674306c62ffd Mon Sep 17 00:00:00 2001 From: Antoine Gourlay Date: Mon, 18 Aug 2014 10:18:46 +0200 Subject: [nomaster] SI-8764 fix return type of case class productElement under Xexperimental Under Xexperimental, productElement now returns the lub instead of the weak lub of case class parameter types (numeric widening shouldn't magically happen *inside* productElement). This was removed from 2.12.x in 6317ae2. --- test/files/neg/t8764.check | 6 ++++++ test/files/neg/t8764.flags | 1 + test/files/neg/t8764.scala | 9 +++++++++ test/files/run/t8764.check | 5 +++++ test/files/run/t8764.flags | 1 + test/files/run/t8764.scala | 16 ++++++++++++++++ 6 files changed, 38 insertions(+) create mode 100644 test/files/neg/t8764.check create mode 100644 test/files/neg/t8764.flags create mode 100644 test/files/neg/t8764.scala create mode 100644 test/files/run/t8764.check create mode 100644 test/files/run/t8764.flags create mode 100644 test/files/run/t8764.scala (limited to 'test') 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}") +} -- cgit v1.2.3