Skip to content

Commit 486f92c

Browse files
committed
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.
1 parent a8bfa82 commit 486f92c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/compiler/scala/tools/nsc/transform/Flatten.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ abstract class Flatten extends InfoTransform {
166166
override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
167167
val stats1 = super.transformStats(stats, exprOwner)
168168
if (currentOwner.isPackageClass) {
169-
val lifted = liftedDefs(currentOwner).toList
169+
val lifted = liftedDefs.remove(currentOwner).toList.flatten
170170
stats1 ::: lifted
171171
}
172172
else stats1

src/compiler/scala/tools/nsc/transform/LambdaLift.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,11 @@ abstract class LambdaLift extends InfoTransform {
539539
override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
540540
def addLifted(stat: Tree): Tree = stat match {
541541
case ClassDef(_, _, _, _) =>
542-
val lifted = liftedDefs get stat.symbol match {
542+
val lifted = liftedDefs remove stat.symbol match {
543543
case Some(xs) => xs reverseMap addLifted
544544
case _ => log("unexpectedly no lifted defs for " + stat.symbol) ; Nil
545545
}
546-
try deriveClassDef(stat)(impl => deriveTemplate(impl)(_ ::: lifted))
547-
finally liftedDefs -= stat.symbol
546+
deriveClassDef(stat)(impl => deriveTemplate(impl)(_ ::: lifted))
548547

549548
case DefDef(_, _, _, _, _, Block(Nil, expr)) if !stat.symbol.isConstructor =>
550549
deriveDefDef(stat)(_ => expr)

0 commit comments

Comments
 (0)