diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala | 2 | ||||
-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 |
7 files changed, 39 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index d0237fb468..bedca88974 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -95,7 +95,7 @@ trait SyntheticMethods extends ast.TreeDSL { // which they shouldn't. val accessorLub = ( if (settings.Xexperimental) { - global.weakLub(accessors map (_.tpe.finalResultType)) match { + global.lub(accessors map (_.tpe.finalResultType)) match { case RefinedType(parents, decls) if !decls.isEmpty => intersectionType(parents) case tp => tp } 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}") +} |