Skip to content

Commit 9a84842

Browse files
committed
Always run ensureOuterAccessors at phase explicitOuter + 1
1 parent a1bc154 commit 9a84842

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,11 @@ object ExplicitOuter {
132132
import ast.tpd._
133133

134134
/** Ensure that class `cls` has outer accessors */
135-
def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit = {
136-
//todo: implementing #165 would simplify this logic
137-
val prevPhase = ctx.phase.prev
138-
assert(prevPhase.id <= ctx.explicitOuterPhase.id, "can add $outer symbols only before ExplicitOuter")
139-
assert(prevPhase.isInstanceOf[DenotTransformer], "adding outerAccessors requires being DenotTransformer")
140-
if (!hasOuter(cls)) {
141-
newOuterAccessors(cls).foreach(_.enteredAfter(prevPhase.asInstanceOf[DenotTransformer]))
135+
def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit =
136+
ctx.atPhase(ctx.explicitOuterPhase.next) { implicit ctx =>
137+
if (!hasOuter(cls))
138+
newOuterAccessors(cls).foreach(_.enteredAfter(ctx.explicitOuterPhase.asInstanceOf[DenotTransformer]))
142139
}
143-
}
144140

145141
/** The outer accessor and potentially outer param accessor needed for class `cls` */
146142
private def newOuterAccessors(cls: ClassSymbol)(implicit ctx: Context) =

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ object PatternMatcher {
768768
def outerTest: Tree = trans.transformFollowingDeep {
769769
val expectedOuter = singleton(expectedTp.normalizedPrefix)
770770
val expectedClass = expectedTp.dealias.classSymbol.asClass
771-
ExplicitOuter.ensureOuterAccessors(expectedClass)(ctx.withPhase(ctx.explicitOuterPhase.next))
771+
ExplicitOuter.ensureOuterAccessors(expectedClass)
772772
scrutinee.ensureConforms(expectedTp)
773773
.outerSelect(1, expectedOuter.tpe.widen)
774774
.select(defn.Object_eq)

0 commit comments

Comments
 (0)