summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-04-13 18:52:12 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-04-14 11:50:27 +0200
commit3515ac4449c72992be411e1e0579d76189dc7bf1 (patch)
treedac0bcf20a2fd49d6cacefbb9c7014b02a2f6a56 /src/compiler
parentd383f458aa5c53629727c5b6abb5134218471543 (diff)
downloadscala-3515ac4449c72992be411e1e0579d76189dc7bf1.tar.gz
scala-3515ac4449c72992be411e1e0579d76189dc7bf1.tar.bz2
scala-3515ac4449c72992be411e1e0579d76189dc7bf1.zip
more prudent bridging to unapply[Seq]
since we can't statically know whether the unapply we'll be bridging to is synthetic, drop this condition, and do pessimistic bridging for all unapply[Seq] (i.e., if we can't statically guarantee the type that would be assumed to be safe to cast to by a synthetic extractor, do the type test and return None if it fails)
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index bdf2f2883f..5e61359a25 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -480,11 +480,10 @@ abstract class Erasure extends AddInterfaces
// TODO: should we do this for user-defined unapplies as well?
// does the first argument list have exactly one argument -- for user-defined unapplies we can't be sure
def maybeWrap(bridgingCall: Tree): Tree = {
- val canReturnNone = afterErasure(
- member.isSynthetic
- && (member.name == nme.unapply || member.name == nme.unapplySeq)
- && !(member.tpe <:< other.tpe) // no static guarantees (TODO: is the subtype test ever true?)
- )
+ val canReturnNone = ( // can't statically know which member is going to be selected, so don't let this depend on member.isSynthetic
+ (member.name == nme.unapply || member.name == nme.unapplySeq)
+ && !afterErasure((member.tpe <:< other.tpe))) // no static guarantees (TODO: is the subtype test ever true?)
+
if (canReturnNone) {
import CODE._
val typeTest = gen.mkIsInstanceOf(REF(bridge.firstParam), member.tpe.params.head.tpe)