diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-10-01 17:10:14 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-11-11 15:52:33 -0800 |
commit | fc2cd22efa9c195a28500b0cf679e50498eda480 (patch) | |
tree | bb4e2c58ae8611d7ed7aeaf619f92e389c89fda5 | |
parent | 18dba5054bf39d99aa66728eacc969c9a63bf758 (diff) | |
download | scala-fc2cd22efa9c195a28500b0cf679e50498eda480.tar.gz scala-fc2cd22efa9c195a28500b0cf679e50498eda480.tar.bz2 scala-fc2cd22efa9c195a28500b0cf679e50498eda480.zip |
Review feedback from lrytz: better comments
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Constructors.scala | 24 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Statics.scala | 3 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 32fdba4d36..2f019c75c9 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -300,16 +300,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { satelliteClass.asInstanceOf[ClassDef] } - /** For a DelayedInit subclass, wrap remainingConstrStats into a DelayedInit closure. - * - * TODO: XXX This condition (`isDelayedInitSubclass && remainingConstrStats.nonEmpty`) is not correct: - * remainingConstrStats.nonEmpty excludes too much, - * but excluding it includes too much. The constructor sequence being mimicked - * needs to be reproduced with total fidelity. - * - * See test case files/run/bug4680.scala, the output of which is wrong in many - * particulars. - */ + /** For a DelayedInit subclass, wrap remainingConstrStats into a DelayedInit closure. */ def delayedInitDefsAndConstrStats(defs: List[Tree], remainingConstrStats: List[Tree]): (List[Tree], List[Tree]) = { val delayedHook = delayedEndpointDef(remainingConstrStats) val delayedHookSym = delayedHook.symbol.asInstanceOf[MethodSymbol] @@ -670,8 +661,8 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { if (isDelayedInitSubclass) Set.empty else computeOmittableAccessors(clazz, defs, auxConstructors) - // TODO: need to add the following disjunction to omittableSym to omit symbol corresponding to suppressed ValDef tree... - // `|| (sym.isValue && !sym.isMethod && !memoizeValue(sym))` + // TODO: this should omit fields for non-memoized (constant-typed, unit-typed vals need no storage -- + // all the action is in the getter) def omittableSym(sym: Symbol) = omittableAccessor(sym) def omittableStat(stat: Tree) = omittableSym(stat.symbol) @@ -703,6 +694,15 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { } val (uptoSuperStats, remainingConstrStats) = splitAtSuper(constructorStats) + + /* TODO: XXX This condition (`isDelayedInitSubclass && remainingConstrStats.nonEmpty`) is not correct: + * remainingConstrStats.nonEmpty excludes too much, + * but excluding it includes too much. The constructor sequence being mimicked + * needs to be reproduced with total fidelity. + * + * See test case files/run/bug4680.scala, the output of which is wrong in many + * particulars. + */ val (delayedHookDefs, remainingConstrStatsDelayedInit) = if (isDelayedInitSubclass && remainingConstrStats.nonEmpty) delayedInitDefsAndConstrStats(defs, remainingConstrStats) else (Nil, remainingConstrStats) diff --git a/src/compiler/scala/tools/nsc/transform/Statics.scala b/src/compiler/scala/tools/nsc/transform/Statics.scala index 6a872b2484..9ab00f1a83 100644 --- a/src/compiler/scala/tools/nsc/transform/Statics.scala +++ b/src/compiler/scala/tools/nsc/transform/Statics.scala @@ -5,8 +5,7 @@ abstract class Statics extends Transform with ast.TreeDSL { import global._ class StaticsTransformer extends Transformer { - /** changes the template for the class so that it contains a static constructor with symbol fields inits, - * augments an existing static ctor if one already existed. + /** generate a static constructor with symbol fields inits, or an augmented existing static ctor */ def staticConstructor(body: List[Tree], localTyper: analyzer.Typer, pos: Position)(newStaticInits: List[Tree]): Tree = body.collectFirst { |