Skip to content

Commit aebd4c5

Browse files
isLoading variable replaced with a flag for performance reasons
1 parent d8a51f2 commit aebd4c5

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ object Flags {
406406
/** A denotation that is valid in all run-ids */
407407
val (Permanent @ _, _, _) = newFlags(61, "<permanent>")
408408

409+
/** Denotation is being loaded. If `Completing` is not set,
410+
* this means this denotation was loaded from an external file.
411+
*/
412+
val (Loading @ _, _, _) = newFlags(62, "<loading>")
413+
409414
// --------- Combined Flag Sets and Conjunctions ----------------------
410415

411416
/** All possible flags */

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,6 @@ object SymDenotations {
149149
private var myPrivateWithin: Symbol = initPrivateWithin
150150
private var myAnnotations: List[Annotation] = Nil
151151

152-
private[this] var isLoading = false
153-
private[this] var wasLoaded = false
154-
155-
def startedLoading() =
156-
isLoading = true
157-
158-
def finishedLoading() =
159-
isLoading = false
160-
wasLoaded = true
161-
162152
/** The owner of the symbol; overridden in NoDenotation */
163153
def owner: Symbol = maybeOwner
164154

@@ -171,12 +161,19 @@ object SymDenotations {
171161
private[dotc] final def flagsUNSAFE: FlagSet = myFlags
172162

173163
private def setMyFlags(flags: FlagSet) =
174-
lazy val immutableFlags = if wasLoaded then AfterLoadFlags else FromStartFlags
164+
lazy val immutableFlags = if myInfo.isInstanceOf[SymbolLoader] then AfterLoadFlags else FromStartFlags
175165
lazy val changedImmutableFlags = (myFlags ^ flags) & immutableFlags
176-
if myFlags.is(Touched) && !isLoading then assert(changedImmutableFlags.isEmpty,
166+
if myFlags.is(Touched, butNot = Loading) then assert(changedImmutableFlags.isEmpty,
177167
s"Illegal mutation of flags ${changedImmutableFlags.flagsString} on completion of $this")
178168
myFlags = flags
179169

170+
final def startedLoading() =
171+
myFlags |= Loading
172+
173+
final def finishedLoading() =
174+
myFlags &~= Loading
175+
176+
180177
final def flagsString(implicit ctx: Context): String = flags.flagsString
181178

182179
/** Adapt flag set to this denotation's term or type nature */

0 commit comments

Comments
 (0)