Skip to content

Commit 7602f43

Browse files
committed
Set owner of context correctly
1 parent cd3aef2 commit 7602f43

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Checker extends MiniPhase {
5252
thisClass = cls,
5353
fieldsInited = mutable.Set.empty,
5454
parentsInited = mutable.Set.empty,
55-
env = baseEnv.withCtx(ctx)
55+
env = baseEnv.withCtx(ctx.withOwner(cls))
5656
)
5757

5858
Checking.checkClassBody(tree)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ object Checking {
146146
}
147147

148148
private def check(eff: Effect)(implicit state: State): Errors =
149-
if (state.visited.contains(eff)) Errors.empty else trace("checking effect " + eff.show, init, errs => Errors.show(errs.asInstanceOf[Errors])) {
149+
if (state.visited.contains(eff)) Errors.empty
150+
else trace("checking effect " + eff.show, init, errs => Errors.show(errs.asInstanceOf[Errors])) {
150151
implicit val state2: State = state.withVisited(eff)
151152

152153
eff match {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ object Potentials {
8888
}
8989

9090
def resolveOuter(cur: ClassSymbol, outerPots: Potentials, cls: ClassSymbol)(implicit env: Env): Potentials =
91+
trace("resolveOuter for " + cls.show + ", outer = " + show(outerPots) + ", cur = " + cur.show, init, s => Potentials.show(s.asInstanceOf[Potentials])) {
9192
if (cur == cls) outerPots
9293
else {
9394
val bottomClsSummary = env.summaryOf(cur)
@@ -98,6 +99,7 @@ object Potentials {
9899
case None => ??? // impossible
99100
}
100101
}
102+
}
101103

102104
/** The Outer potential for `classSymbol` of the object `pot`
103105
*

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,13 @@ 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+
val enclosing = cur.owner.lexicallyEnclosingClass.asClass
256257
if (cls.is(Flags.Package)) (Potentials.empty, Effects.empty)
257-
else if (cls == cur) (pot.toPots, Effects.empty)
258+
else if (cls == cur || enclosing.is(Flags.Package)) (pot.toPots, Effects.empty)
258259
else if (pot.size > 2) (Potentials.empty, Promote(pot)(source).toEffs)
259260
else {
260261
val pot2 = Outer(pot, cur)(pot.source)
261-
resolveThis(cls, pot2, cur.lexicallyEnclosingClass.asClass, source)
262+
resolveThis(cls, pot2, enclosing, source)
262263
}
263264
}
264265

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ object Summary {
3232
def summaryOf(member: Symbol)(implicit env: Env): Summary =
3333
if (summaryCache.contains(member)) summaryCache(member)
3434
else trace("summary for " + member.show, init, s => Summary.show(s.asInstanceOf[Summary])) {
35+
implicit val env2 = env.withOwner(member)
3536
val summary =
3637
if (member.isConstructor)
3738
Summarization.analyzeConstructor(member)

0 commit comments

Comments
 (0)