diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 8e6e315f7d..a2575e59ad 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -180,11 +180,6 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { private def isSeqClass(sym: Symbol) = (SeqClass isNonBottomSubClass sym) && (sym != ObjectClass) - /** Decides if sym is a supertype of array, right now that includes - from RandomAccessSeq.Mutable */ - private def isArraySuper(sym: Symbol) = - (RandomAccessSeqMutableClass isNonBottomSubClass sym) //&& (sym != ObjectClass) - // -------- boxing/unboxing -------------------------------------------------------- override def newTyper(context: Context) = new Eraser(context) @@ -282,8 +277,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { private def cast(tree: Tree, pt: Type): Tree = { assert(pt eq pt.normalize) - if (isArraySuper(tree.tpe.typeSymbol)) { // == ObjectClass) { - if (pt.typeSymbol == ArrayClass) { + if (tree.tpe.typeSymbol == ObjectClass) { + if (pt.typeSymbol == ArrayClass) typed { atPos(tree.pos) { gen.evalOnce(tree, context.owner, context.unit) { x => @@ -300,7 +295,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } } } - } else if (pt.typeSymbol isNonBottomSubClass BoxedArrayClass) { + else if (pt.typeSymbol isNonBottomSubClass BoxedArrayClass) typed { atPos(tree.pos) { gen.evalOnce(tree, context.owner, context.unit) { x => @@ -317,7 +312,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } } } - } else if (isArraySuper(pt.typeSymbol)) { + else if (isSeqClass(pt.typeSymbol)) typed { atPos(tree.pos) { gen.evalOnce(tree, context.owner, context.unit) { x => @@ -334,7 +329,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } } } - } else gen.mkAttributedCast(tree, pt) + else gen.mkAttributedCast(tree, pt) } else gen.mkAttributedCast(tree, pt) } @@ -444,18 +439,16 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { val qual1 = typedQualifier(qual) val qualClass = qual1.tpe.typeSymbol val targClass = targ.tpe.typeSymbol - /* if (isNumericValueClass(qualClass) && isNumericValueClass(targClass)) // convert numeric type casts atPos(tree.pos)(Apply(Select(qual1, "to" + targClass.name), List())) else */ - assert(true) if (isValueType(targClass) || (targClass == ArrayClass && (qualClass isNonBottomSubClass BoxedArrayClass))) unbox(qual1, targ.tpe) - else if (((targClass == ArrayClass || isArraySuper(targClass)) && isArraySuper(qualClass))) + else if (targClass == ArrayClass && qualClass == ObjectClass || isSeqClass(targClass)) cast(qual1, targ.tpe) else tree @@ -832,7 +825,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { } } case _ => - if (isArraySuper(targ.tpe.typeSymbol)) { + if (isSeqClass(targ.tpe.typeSymbol)) { atPos(tree.pos) { gen.evalOnce(qual, currentOwner, unit) { q => gen.mkOr( @@ -842,12 +835,6 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { }) } } - } else if (isArraySuper(qual.tpe.typeSymbol) && targ.tpe.typeSymbol == ArrayClass) { - gen.evalOnce(qual, currentOwner, unit) { q => - atPos(tree.pos) { - Apply(gen.mkAttributedRef(isArrayMethod), List(q())) - } - } } else tree } case _ => tree |