File tree 1 file changed +6
-4
lines changed
src/dotty/tools/dotc/transform 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,13 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
34
34
35
35
override def phaseName = " firstTransform"
36
36
37
- private var needsCompanionPredicate : ClassSymbol => Boolean = null
37
+ private var addCompanionPhases : List [NeedsCompanions ] = _
38
+
39
+ def needsCompanion (cls : ClassSymbol )(implicit ctx : Context ) =
40
+ addCompanionPhases.exists(_.isCompanionNeeded(cls))
38
41
39
42
override def prepareForUnit (tree : tpd.Tree )(implicit ctx : Context ): TreeTransform = {
40
- needsCompanionPredicate = ctx.phasePlan.flatMap(_.filter(x => x.isInstanceOf [NeedsCompanions ])).
41
- foldLeft((x : ClassSymbol ) => false )((pred, phase) => x => pred(x) || phase.asInstanceOf [NeedsCompanions ].isCompanionNeeded(x))
43
+ addCompanionPhases = ctx.phasePlan.flatMap(_ collect { case p : NeedsCompanions => p })
42
44
this
43
45
}
44
46
@@ -90,7 +92,7 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
90
92
}
91
93
92
94
def addMissingCompanions (stats : List [Tree ]): List [Tree ] = stats map {
93
- case stat : TypeDef if (singleClassDefs contains stat.name) && needsCompanionPredicate (stat.symbol.asClass) =>
95
+ case stat : TypeDef if (singleClassDefs contains stat.name) && needsCompanion (stat.symbol.asClass) =>
94
96
val objName = stat.name.toTermName
95
97
val nameClash = stats.exists {
96
98
case other : MemberDef =>
You can’t perform that action at this time.
0 commit comments