Skip to content

Commit 83b2f66

Browse files
committed
Handle usage of O$.this outside of object O
1 parent 3dc1129 commit 83b2f66

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/transform/init/Summarization.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,16 @@ object Summarization {
253253

254254
def resolveThis(cls: ClassSymbol, pot: Potential, cur: ClassSymbol, source: Tree)(implicit env: Env): Summary =
255255
trace("resolve " + cls.show + ", pot = " + pot.show + ", cur = " + cur.show, init, s => Summary.show(s.asInstanceOf[Summary])) {
256-
if (cls.is(Flags.Package)) (Potentials.empty, Effects.empty)
256+
if (cls.is(Flags.Package)) Summary.empty
257257
else if (cls == cur) (pot.toPots, Effects.empty)
258258
else if (pot.size > 2) (Potentials.empty, Promote(pot)(source).toEffs)
259259
else {
260-
val pot2 = Outer(pot, cur)(pot.source)
261260
val enclosing = cur.owner.lexicallyEnclosingClass.asClass
261+
// Dotty uses O$.this outside of the object O
262+
if (enclosing.is(Flags.Package) && cls.is(Flags.Module)) return Summary.empty
263+
262264
assert(!enclosing.is(Flags.Package), "enclosing = " + enclosing.show + ", cls = " + cls.show + ", pot = " + pot.show + ", cur = " + cur.show)
265+
val pot2 = Outer(pot, cur)(pot.source)
263266
resolveThis(cls, pot2, enclosing, source)
264267
}
265268
}

0 commit comments

Comments
 (0)