diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2011-01-18 16:27:38 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2011-01-18 16:27:38 +0000 |
commit | 60f1b4b1c46719093f73b394e8680e03edf7fd4b (patch) | |
tree | cb4c527f3a3995ec60036f885c899a99a192befb /src | |
parent | cbfb5d387b334a03c404a3ae580d3ab5858816e3 (diff) | |
download | scala-60f1b4b1c46719093f73b394e8680e03edf7fd4b.tar.gz scala-60f1b4b1c46719093f73b394e8680e03edf7fd4b.tar.bz2 scala-60f1b4b1c46719093f73b394e8680e03edf7fd4b.zip |
Allow box(unbox) elimination for the Null type,...
Allow box(unbox) elimination for the Null type, plus testing that
specialization tests do not box too much. review by extempore.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 5de5bd9a99..998cf69f5e 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -440,6 +440,9 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. /** The modifier typer which retypes with erased types. */ class Eraser(context: Context) extends Typer(context) { + private def safeToRemoveUnbox(cls: Symbol): Boolean = + (cls == definitions.NullClass) || isBoxedValueClass(cls) + /** Box `tree' of unboxed type */ private def box(tree: Tree): Tree = tree match { case LabelDef(name, params, rhs) => @@ -455,8 +458,11 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. tree match { /** Can't always remove a Box(Unbox(x)) combination because the process of boxing x * may lead to throwing an exception. + * + * This is important for specialization: calls to the super constructor should not box/unbox specialized + * fields (see TupleX). (ID) */ - case Apply(boxFun, List(arg)) if isUnbox(tree.symbol) && isBoxedValueClass(arg.tpe.typeSymbol) => + case Apply(boxFun, List(arg)) if isUnbox(tree.symbol) && safeToRemoveUnbox(arg.tpe.typeSymbol) => log("boxing an unbox: " + tree + " and replying with " + arg) arg case _ => |