Skip to content

Commit

Permalink
Refactor transformStats impls for consistency
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
retronym committed Feb 3, 2015
1 parent a8bfa82 commit 486f92c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/Flatten.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/scala/tools/nsc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 486f92c

Please sign in to comment.