From 3515ac4449c72992be411e1e0579d76189dc7bf1 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 13 Apr 2012 18:52:12 +0200 Subject: 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) --- src/compiler/scala/tools/nsc/transform/Erasure.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/compiler') 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) -- cgit v1.2.3