10000 check symbol table phase in openPackageModule · scala/scala@a3676f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3676f0

Browse files
committed
check symbol table phase in openPackageModule
1 parent 91480ef commit a3676f0

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
8282
def findMemberFromRoot(fullName: Name): Symbol = rootMirror.findMemberFromRoot(fullName)
8383

8484
override def openPackageModule(pkgClass: Symbol, force: Boolean): Unit = {
85-
if (force || isPast(currentRun.namerPhase)) super.openPackageModule(pkgClass, force = true)
85+
// presentation compiler uses `compileLate` whioch doesn't advance `globalPhase`, so `isPast` is false.
86+
// therefore checking `isAtPhaseAfter` as well.
87+
val forceNow = force || isPast(currentRun.namerPhase) || isRunGlobalInitialized && isAtPhaseAfter(currentRun.namerPhase)
88+
if (forceNow) super.openPackageModule(pkgClass, force = true)
8689
else analyzer.packageObjects.deferredOpen.addOne(pkgClass)
8790
}
88-
8991
// alternate constructors ------------------------------------------
9092

9193
override def settings = currentSettings
@@ -1037,25 +1039,16 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
10371039
private[this] var curFreshNameCreator: FreshNameCreator = null
10381040
private[scala] def currentFreshNameCreator_=(fresh: FreshNameCreator): Unit = curFreshNameCreator = fresh
10391041

1040-
def isGlobalInitialized = (
1041-
definitions.isDefinitionsInitialized
1042-
&& rootMirror.isMirrorInitialized
1043-
)
1042+
def isGlobalInitialized = definitions.isDefinitionsInitialized && rootMirror.isMirrorInitialized
1043+
private def isRunGlobalInitialized = (curRun ne null) && isGlobalInitialized
1044+
10441045
override def isPastTyper = isPast(currentRun.typerPhase)
10451046
def isBeforeErasure = isBefore(currentRun.erasurePhase)
1046-
def isPast(phase: Phase) = (
1047-
(curRun ne null)
1048-
&& isGlobalInitialized // defense against init order issues
1049-
&& (globalPhase.id > phase.id)
1050-
)
1051-
def isBefore(phase: Phase) = (
1052-
(curRun ne null)
1053-
&& isGlobalInitialized // defense against init order issues
1054-
&& (phase match {
1055-
case NoPhase => true // if phase is NoPhase then that phase ain't comin', so we're "before it"
1056-
case _ => globalPhase.id < phase.id
1057-
})
1058-
)
1047+
def isPast(phase: Phase) = isRunGlobalInitialized && (globalPhase.id > phase.id)
1048+
def isBefore(phase: Phase) = isRunGlobalInitialized && (phase match {
1049+
case NoPhase => true // if phase is NoPhase then that phase ain't comin', so we're "before it"
1050+
case _ => globalPhase.id < phase.id
1051+
})
10591052

10601053
// TODO - trim these to the absolute minimum.
10611054
@inline final def exitingErasure[T](op: => T): T = exitingPhase(currentRun.erasurePhase)(op)

src/compiler/scala/tools/nsc/typechecker/Analyzer.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ trait Analyzer extends AnyRef
8080

8181
def apply(unit: CompilationUnit): Unit = {
8282
openPackageObjectsTraverser(unit.body)
83-
/* Force parameter needed to force loading package object symbols
84-
* since globalPhase may not be past namer when compileLate
85-
* Related to https://github.com/scala/scala/pull/10988
86-
* */
87-
deferredOpen.foreach(openPackageModule(_, force = true))
83+
deferredOpen.foreach(openPackageModule(_))
8884
deferredOpen.clear()
8985
}
9086
}

src/interactive/scala/tools/nsc/interactive/Global.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
403403
case unit: RichCompilationUnit => unit.isParsed
404404
case _ => true
405405
})
406-
if (isPastNamer) super.openPackageModule(pkgClass, force = true)
407-
else analyzer.packageObjects.deferredOpen.add(pkgClass)
406+
super.openPackageModule(pkgClass, force = isPastNamer)
408407
}
409408

410409
// ----------------- Polling ---------------------------------------

0 commit comments

Comments
 (0)
0