diff options
author | Martin Odersky <odersky@gmail.com> | 2010-12-14 17:05:06 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2010-12-14 17:05:06 +0000 |
commit | e671d760128a8afe9de65b282a7998f4ac8e2d9c (patch) | |
tree | d041cbcda6f062b5a4cd42c8a97d507b553c7027 /src | |
parent | 2bb5d585de3991a7d259fc738462e15ec2d38952 (diff) | |
download | scala-e671d760128a8afe9de65b282a7998f4ac8e2d9c.tar.gz scala-e671d760128a8afe9de65b282a7998f4ac8e2d9c.tar.bz2 scala-e671d760128a8afe9de65b282a7998f4ac8e2d9c.zip |
Enabled delayedInit. Review by extempore.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Constructors.scala | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index aec00bfb33..57f3ffe801 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -450,14 +450,14 @@ abstract class Constructors extends Transform with ast.TreeDSL { vparamss = List(List()), rhs = Block(applyMethodStats, gen.mkAttributedRef(BoxedUnit_UNIT))) - util.trace("delayedInit: ") { ClassDef( + ClassDef( sym = closureClass, constrMods = Modifiers(0), vparamss = List(List(outerFieldDef)), argss = List(List()), body = List(outerFieldDef, applyMethodDef), superPos = impl.pos) - }} + } } def delayedInitCall(closure: Tree) = @@ -469,20 +469,23 @@ abstract class Constructors extends Transform with ast.TreeDSL { } } - /** Return a pair consisting of (all statements up to and icnluding superclass constr call, rest) */ - def splitAtSuper(stats: List[Tree]) = - stats.span(tree => !((tree.symbol ne null) && tree.symbol.isConstructor)) match { - case (prefix, supercall :: rest) => (prefix :+ supercall, rest) - case p => p - } + /** Return a pair consisting of (all statements up to and including superclass and trait constr calls, rest) */ + def splitAtSuper(stats: List[Tree]) = { + def isConstr(tree: Tree) = (tree.symbol ne null) && tree.symbol.isConstructor + val (pre, rest0) = stats span (!isConstr(_)) + val (supercalls, rest) = rest0 span (isConstr(_)) + (pre ::: supercalls, rest) + } var (uptoSuperStats, remainingConstrStats) = splitAtSuper(constrStatBuf.toList) val needsDelayedInit = - false && (clazz isSubClass DelayedInitClass) && !(defBuf exists isInitDef) && remainingConstrStats.nonEmpty + (clazz isSubClass DelayedInitClass) && !(defBuf exists isInitDef) && remainingConstrStats.nonEmpty if (needsDelayedInit) { - remainingConstrStats = List(delayedInitCall(delayedInitClosure(remainingConstrStats))) + val dicl = delayedInitClosure(remainingConstrStats) + defBuf += dicl + remainingConstrStats = List(delayedInitCall(dicl)) } // Assemble final constructor |