diff options
author | Antoine Gourlay <antoine@gourlay.fr> | 2014-09-08 08:51:39 +0200 |
---|---|---|
committer | Antoine Gourlay <antoine@gourlay.fr> | 2014-09-08 09:53:10 +0200 |
commit | 6317ae2dbb49f271ff9bba482f8ce38f2ffafe52 (patch) | |
tree | cd9d4981adb48cf600097c0f19e5fe8eed2dc7d2 /src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala | |
parent | 5fac01e5a482370e706380822a6c21981697c83b (diff) | |
download | scala-6317ae2dbb49f271ff9bba482f8ce38f2ffafe52.tar.gz scala-6317ae2dbb49f271ff9bba482f8ce38f2ffafe52.tar.bz2 scala-6317ae2dbb49f271ff9bba482f8ce38f2ffafe52.zip |
SI-8764 remove Xexperimental special Product members for case classes
`productElement` and `productIterator` return types under Xexperimental
use the weak lub of the case class's parameters instead of just Any.
This isn't really useful, nor tested and it is broken (SI-8764) anyway.
The special casing of `productElement` and `productIterator` was
introduced with `ProductN` support in case classes (e412524), but was
not removed when `ProductN` support went away (70996f8, d7f498a,
b7395e9, 317a105).
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 9516f94135..14653a38e1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -84,24 +84,6 @@ trait SyntheticMethods extends ast.TreeDSL { def accessors = clazz.caseFieldAccessors val arity = accessors.size - // If this is ProductN[T1, T2, ...], accessorLub is the lub of T1, T2, ..., . - // !!! Hidden behind -Xexperimental due to bummer type inference bugs. - // Refining from Iterator[Any] leads to types like - // - // Option[Int] { def productIterator: Iterator[String] } - // - // appearing legitimately, but this breaks invariant places - // like Tags and Arrays which are not robust and infer things - // which they shouldn't. - val accessorLub = ( - if (settings.Xexperimental) { - global.weakLub(accessors map (_.tpe.finalResultType)) match { - case RefinedType(parents, decls) if !decls.isEmpty => intersectionType(parents) - case tp => tp - } - } - else AnyTpe - ) def forwardToRuntime(method: Symbol): Tree = forwardMethod(method, getMember(ScalaRunTimeModule, (method.name prepend "_")))(mkThis :: _) @@ -122,8 +104,8 @@ trait SyntheticMethods extends ast.TreeDSL { } } def productIteratorMethod = { - createMethod(nme.productIterator, iteratorOfType(accessorLub))(_ => - gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(accessorLub), List(mkThis)) + createMethod(nme.productIterator, iteratorOfType(AnyTpe))(_ => + gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(AnyTpe), List(mkThis)) ) } @@ -243,7 +225,7 @@ trait SyntheticMethods extends ast.TreeDSL { List( Product_productPrefix -> (() => constantNullary(nme.productPrefix, clazz.name.decode)), Product_productArity -> (() => constantNullary(nme.productArity, arity)), - Product_productElement -> (() => perElementMethod(nme.productElement, accessorLub)(mkThisSelect)), + Product_productElement -> (() => perElementMethod(nme.productElement, AnyTpe)(mkThisSelect)), Product_iterator -> (() => productIteratorMethod), Product_canEqual -> (() => canEqualMethod) // This is disabled pending a reimplementation which doesn't add any |