Skip to content

Commit cdbe81e

Browse files
committed
Fix #440: entering symbol into scope also enters it into future scopes.
1 parent b653007 commit cdbe81e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ object Denotations {
471471
* 2) the union of all validity periods is a contiguous
472472
* interval.
473473
*/
474-
private var nextInRun: SingleDenotation = this
474+
protected var nextInRun: SingleDenotation = this
475475

476476
/** The version of this SingleDenotation that was valid in the first phase
477477
* of this run.

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,15 +1275,17 @@ object SymDenotations {
12751275
myMemberCache
12761276
}
12771277

1278-
/** Enter a symbol in current scope.
1278+
/** Enter a symbol in current scope, and future scopes of same denotation.
12791279
* Note: We require that this does not happen after the first time
12801280
* someone does a findMember on a subclass.
12811281
* @param scope The scope in which symbol should be entered.
12821282
* If this is EmptyScope, the scope is `decls`.
12831283
*/
12841284
def enter(sym: Symbol, scope: Scope = EmptyScope)(implicit ctx: Context): Unit = {
12851285
val mscope = scope match {
1286-
case scope: MutableScope => scope
1286+
case scope: MutableScope =>
1287+
assert(this.nextInRun == this) // we are not going to bring this symbol into future
1288+
scope
12871289
case _ => unforcedDecls.openForMutations
12881290
}
12891291
if (this is PackageClass) {
@@ -1295,6 +1297,10 @@ object SymDenotations {
12951297
}
12961298
}
12971299
enterNoReplace(sym, mscope)
1300+
val nxt = this.nextInRun
1301+
if((nxt ne this) && (nxt.validFor.code > this.validFor.code)) {
1302+
this.nextInRun.asSymDenotation.asClass.enter(sym)
1303+
}
12981304
}
12991305

13001306
/** Enter a symbol in given `scope` without potentially replacing the old copy. */

0 commit comments

Comments
 (0)