Skip to content

Commit e65f8da

Browse files
committed
Replaced overridden init methods with prepareForUnit.
This allows to move to a functional implementation later. Only exception: CapturedVars still uses init() because it contains a (dubious!) interaction with intialization and transformSym. Looking at this next.
1 parent cf12129 commit e65f8da

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/dotty/tools/dotc/transform/CollectEntryPoints.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import dotty.tools.dotc.config.JavaPlatform
2626
class CollectEntryPoints extends MiniPhaseTransform {
2727

2828
/** perform context-dependant initialization */
29-
override def init(implicit ctx: Context, info: TransformerInfo): Unit = {
29+
override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context) = {
3030
entryPoints = collection.immutable.TreeSet.empty[Symbol](new SymbolOrdering())
3131
assert(ctx.platform.isInstanceOf[JavaPlatform], "Java platform specific phase")
32+
this
3233
}
3334

3435
private var entryPoints: Set[Symbol] = _

src/dotty/tools/dotc/transform/InterceptedMethods.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ class InterceptedMethods extends MiniPhaseTransform {
5353
private var primitiveGetClassMethods: Set[Symbol] = _
5454

5555
/** perform context-dependant initialization */
56-
override def init(implicit ctx: Context, info: TransformerInfo): Unit = {
56+
override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
5757
poundPoundMethods = Set(defn.Any_##)
5858
Any_comparisons = Set(defn.Any_==, defn.Any_!=)
5959
interceptedMethods = poundPoundMethods ++ Any_comparisons
6060
primitiveGetClassMethods = Set[Symbol]() ++ defn.ScalaValueClasses.map(x => x.requiredMethod(nme.getClass_))
61+
this
6162
}
6263

6364
// this should be removed if we have guarantee that ## will get Apply node

src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,26 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this
278278
}
279279
}
280280

281-
override def init(implicit ctx: Context, info: TransformerInfo) =
281+
override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
282282
ctx.atPhase(thisTransform) { implicit ctx =>
283-
free.clear()
284-
proxyMap.clear()
285-
called.clear()
286-
calledFromInner.clear()
287-
liftedOwner.clear()
288-
liftedDefs.clear()
289283
(new CollectDependencies).traverse(NoSymbol, ctx.compilationUnit.tpdTree)
290284
computeFreeVars()
291285
computeLiftedOwners()
292286
generateProxies()(ctx.withPhase(thisTransform.next))
293287
liftLocals()(ctx.withPhase(thisTransform.next))
294288
}
289+
this
290+
}
291+
292+
override def transformUnit(tree: Tree)(implicit ctx: Context, info: TransformerInfo) = {
293+
free.clear()
294+
proxyMap.clear()
295+
called.clear()
296+
calledFromInner.clear()
297+
liftedOwner.clear()
298+
liftedDefs.clear()
299+
tree
300+
}
295301

296302
private def currentEnclosure(implicit ctx: Context) =
297303
ctx.owner.enclosingMethod.skipConstructor

src/dotty/tools/dotc/transform/SyntheticMethods.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ class SyntheticMethods extends MiniPhaseTransform with IdentityDenotTransformer
3939
private var valueSymbols: List[Symbol] = _
4040
private var caseSymbols: List[Symbol] = _
4141

42-
override def init(implicit ctx: Context, info: TransformerInfo) = {
42+
override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
4343
valueSymbols = List(defn.Any_hashCode, defn.Any_equals)
4444
caseSymbols = valueSymbols ++ List(defn.Any_toString, defn.Product_canEqual, defn.Product_productArity)
45+
this
4546
}
4647

4748
/** The synthetic methods of the case or value class `clazz`.

0 commit comments

Comments
 (0)