diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2013-03-24 17:03:08 +0100 |
---|---|---|
committer | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2013-04-24 22:38:07 +0200 |
commit | 72114328447f762ed791832908e0868e45b08e72 (patch) | |
tree | 07251c6dc42ed60e51429f124b14f234d9cbffca | |
parent | 8dc0c3dd4cff261a61f146554d43e75f24c02a4d (diff) | |
download | scala-72114328447f762ed791832908e0868e45b08e72.tar.gz scala-72114328447f762ed791832908e0868e45b08e72.tar.bz2 scala-72114328447f762ed791832908e0868e45b08e72.zip |
avoids multiple evals of isSubClass DelayedInitClass
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Constructors.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index fe8bad3e3a..6c89d8fdce 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -236,7 +236,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { constrStatBuf += intoConstructor(impl.symbol, stat) } - // ----------- avoid making fields for symbols that are not accessed -------------- + // ----------- avoid making parameter-accessor fields for symbols accessed only within the primary constructor -------------- // A sorted set of symbols that are known to be accessed outside the primary constructor. val accessedSyms = new TreeSet[Symbol]((x, y) => x isLess y) @@ -244,6 +244,8 @@ abstract class Constructors extends Transform with ast.TreeDSL { // a list of outer accessor symbols and their bodies var outerAccessors: List[(Symbol, Tree)] = List() + val isDelayedInitSubclass = (clazz isSubClass DelayedInitClass) + // Could symbol's definition be omitted, provided it is not accessed? // This is the case if the symbol is defined in the current class, and // ( the symbol is an object private parameter accessor field, or @@ -251,7 +253,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { def maybeOmittable(sym: Symbol) = sym.owner == clazz && ( sym.isParamAccessor && sym.isPrivateLocal || sym.isOuterAccessor && sym.owner.isEffectivelyFinal && !sym.isOverridingSymbol && - !(clazz isSubClass DelayedInitClass) + !isDelayedInitSubclass ) // Is symbol known to be accessed outside of the primary constructor, @@ -568,7 +570,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { * particulars. */ val needsDelayedInit = - (clazz isSubClass DelayedInitClass) /*&& !(defBuf exists isInitDef)*/ && remainingConstrStats.nonEmpty + isDelayedInitSubclass /*&& !(defBuf exists isInitDef)*/ && remainingConstrStats.nonEmpty if (needsDelayedInit) { val dicl = new ConstructorTransformer(unit) transform delayedInitClosure(remainingConstrStats) |