diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-02-03 15:15:51 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-02-03 15:15:51 +1000 |
commit | 486f92c5ddd6f02cdcd6e32329ce92f90a9fa1c9 (patch) | |
tree | b977a38455821b223ae44b8ff25c55bfc1cbe358 /src | |
parent | a8bfa82dcb470f31953f43e0db46570e7a020855 (diff) | |
download | scala-486f92c5ddd6f02cdcd6e32329ce92f90a9fa1c9.tar.gz scala-486f92c5ddd6f02cdcd6e32329ce92f90a9fa1c9.tar.bz2 scala-486f92c5ddd6f02cdcd6e32329ce92f90a9fa1c9.zip |
Refactor transformStats impls for consistency
Uses the same idiom in `Flatten` and `LambdaLift` as is established
in `Extender` and (recently) `Delambdafy`. This avoids any possibility
of adding a member to a package twice, as used to happen in SI-9097.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Flatten.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala index 6149e40fa7..fbb0307773 100644 --- a/src/compiler/scala/tools/nsc/transform/Flatten.scala +++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala @@ -166,7 +166,7 @@ abstract class Flatten extends InfoTransform { override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = { val stats1 = super.transformStats(stats, exprOwner) if (currentOwner.isPackageClass) { - val lifted = liftedDefs(currentOwner).toList + val lifted = liftedDefs.remove(currentOwner).toList.flatten stats1 ::: lifted } else stats1 diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index fa0c1f797b..a703542587 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -539,12 +539,11 @@ abstract class LambdaLift extends InfoTransform { override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = { def addLifted(stat: Tree): Tree = stat match { case ClassDef(_, _, _, _) => - val lifted = liftedDefs get stat.symbol match { + val lifted = liftedDefs remove stat.symbol match { case Some(xs) => xs reverseMap addLifted case _ => log("unexpectedly no lifted defs for " + stat.symbol) ; Nil } - try deriveClassDef(stat)(impl => deriveTemplate(impl)(_ ::: lifted)) - finally liftedDefs -= stat.symbol + deriveClassDef(stat)(impl => deriveTemplate(impl)(_ ::: lifted)) case DefDef(_, _, _, _, _, Block(Nil, expr)) if !stat.symbol.isConstructor => deriveDefDef(stat)(_ => expr) |