Skip to content

Commit 56e8dfc

Browse files
Tighten flag checking rules on completion
Count a denotation as completing if it has the `Touched` flag set. This assumption follows from the definition of the flag `Touched` provided in its javadoc comment in Flags.scala. Also, this commit unconditionally unsets this flag for all denotations once they are completed. The rationale is, again, to comply with the definition of `Touched`.
1 parent 33d8ed9 commit 56e8dfc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ object SymDenotations {
173173
private def setMyFlags(flags: FlagSet) =
174174
lazy val immutableFlags = if wasLoaded then AfterLoadFlags else FromStartFlags
175175
lazy val changedImmutableFlags = (myFlags ^ flags) & immutableFlags
176-
if isCompleting && !isLoading then assert(changedImmutableFlags.isEmpty,
176+
if myFlags.is(Touched) && !isLoading then assert(changedImmutableFlags.isEmpty,
177177
s"Illegal mutation of flags ${changedImmutableFlags.flagsString} on completion of $this")
178178
myFlags = flags
179179

@@ -254,7 +254,7 @@ object SymDenotations {
254254
indent += 1
255255

256256
if (myFlags.is(Touched)) throw CyclicReference(this)
257-
setMyFlags(myFlags | Touched)
257+
myFlags |= Touched
258258

259259
// completions.println(s"completing ${this.debugString}")
260260
try completer.complete(this)(ctx.withPhase(validFor.firstPhaseId))
@@ -270,9 +270,10 @@ object SymDenotations {
270270
}
271271
else {
272272
if (myFlags.is(Touched)) throw CyclicReference(this)
273-
setMyFlags(myFlags | Touched)
273+
myFlags |= Touched
274274
completer.complete(this)(ctx.withPhase(validFor.firstPhaseId))
275275
}
276+
myFlags &~= Touched
276277

277278
protected[dotc] def info_=(tp: Type): Unit = {
278279
/* // DEBUG

0 commit comments

Comments
 (0)