diff options
author | Martin Odersky <odersky@gmail.com> | 2005-11-11 12:15:57 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-11-11 12:15:57 +0000 |
commit | 47f1199b5c891754fca1c9b6f2450ba8a45c49b8 (patch) | |
tree | 876649574ebce8abe7b72ba21b17e7e9d00419cc | |
parent | 222cbc2dea024584855bf3b5f8c2a5c0ba07cfc3 (diff) | |
download | scala-47f1199b5c891754fca1c9b6f2450ba8a45c49b8.tar.gz scala-47f1199b5c891754fca1c9b6f2450ba8a45c49b8.tar.bz2 scala-47f1199b5c891754fca1c9b6f2450ba8a45c49b8.zip |
*** empty log message ***
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Symbols.scala | 10 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/Erasure.scala | 34 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/ExplicitOuter.scala | 5 |
3 files changed, 40 insertions, 9 deletions
diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala index 29204237db..1400a3a79b 100755 --- a/sources/scala/tools/nsc/symtab/Symbols.scala +++ b/sources/scala/tools/nsc/symtab/Symbols.scala @@ -798,11 +798,11 @@ import Flags._; override def name: Name = if (phase.flatClasses && !hasFlag(METHOD) && rawowner != NoSymbol && !rawowner.isPackageClass) { - if (flatname == nme.EMPTY) { - assert(rawowner.isClass); - flatname = newTermName(rawowner.name.toString() + "$" + rawname); - } - flatname + if (flatname == nme.EMPTY) { + assert(rawowner.isClass); + flatname = newTermName(rawowner.name.toString() + "$" + rawname); + } + flatname } else rawname; override def cloneSymbolImpl(owner: Symbol): Symbol = { diff --git a/sources/scala/tools/nsc/transform/Erasure.scala b/sources/scala/tools/nsc/transform/Erasure.scala index 21b2c6b642..5107dc30a2 100755 --- a/sources/scala/tools/nsc/transform/Erasure.scala +++ b/sources/scala/tools/nsc/transform/Erasure.scala @@ -197,6 +197,15 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { (sym.name == nme.EQ || sym.name == nme.NE) && sym.info.paramTypes.head.symbol == ObjectClass || sym == Object_isInstanceOf || sym == Object_asInstanceOf); + def evalOnce(expr: Tree, within: (() => Tree) => Tree): Tree = + if (treeInfo.isPureExpr(expr)) { + within(() => expr); + } else { + val temp = context.owner.newValue(expr.pos, context.unit.fresh.newName()) + setFlag SYNTHETIC setInfo expr.tpe; + Block(List(ValDef(temp, expr)), within(() => Ident(temp) setType expr.tpe)) + } + /** Adapt `tree' to expected type `pt' */ private def adaptToType(tree: Tree, pt: Type): Tree = { if (settings.debug.value && pt != WildcardType) log("adapting " + tree + ":" + tree.tpe + " to " + pt);//debug @@ -243,12 +252,29 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { if ((tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)) => val qual1 = typedQualifier(qual); val targClass = targ.tpe.symbol; - if (isNumericValueClass(qual1.tpe.symbol) && isNumericValueClass(targClass)) + val qualClass = qual1.tpe.symbol; + if (isNumericValueClass(qualClass) && isNumericValueClass(targClass)) // convert numeric type casts atPos(tree.pos)(Apply(Select(qual1, "to" + targClass.name), List())) else if (isValueClass(targClass) || - (targClass == ArrayClass && (qual1.tpe <:< BoxedArrayClass.tpe))) + (targClass == ArrayClass && (qualClass isSubClass BoxedArrayClass))) unbox(qual1, targ.tpe) + else if (targClass == ArrayClass && qualClass == ObjectClass) + typed { + atPos(tree.pos) { + evalOnce(qual1, x => + gen.cast( + If( + Apply( + TypeApply( + Select(x(), Object_isInstanceOf), + List(TypeTree(BoxedArrayClass.tpe))), + List()), + unbox(x(), targ.tpe), + x()), + targ.tpe)) + } + } else tree case Select(qual, name) if (name != nme.CONSTRUCTOR) => if (tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased) @@ -526,7 +552,9 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer { atPhase(phase.next) { val tree2 = traitTransformer.transform(tree1); if (settings.debug.value) log("tree after addinterfaces: \n" + tree2); - newTyper(startContext).typed(tree2) + newTyper(startContext.make( + unit, tree, startContext.owner, startContext.scope, startContext.imports)) + .typed(tree2) } } } diff --git a/sources/scala/tools/nsc/transform/ExplicitOuter.scala b/sources/scala/tools/nsc/transform/ExplicitOuter.scala index 5c1f2c30ae..5032fc889f 100755 --- a/sources/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/sources/scala/tools/nsc/transform/ExplicitOuter.scala @@ -262,7 +262,10 @@ abstract class ExplicitOuter extends InfoTransform { val outerVal = atPos(tree.pos) { if (qual.isInstanceOf[This]) { assert(outerParam != NoSymbol); outerValue } // (8) - else if (qual.tpe.prefix == NoPrefix) gen.This(currentOwner.enclClass.owner.enclClass) + else if (qual.tpe.prefix == NoPrefix) + gen.This( + if (qual.isInstanceOf[Super]) currentOwner.enclClass.owner.enclClass + else currentOwner.enclClass)//??? else gen.mkQualifier(qual.tpe.prefix); // (7) } copy.Apply(tree, sel, args ::: List(outerVal)) |