8000 Fix the Toolbox and PC failures · scala/scala@17b085a · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 17b085a

Browse files
committed
Fix the Toolbox and PC failures
1 parent 0727f93 commit 17b085a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
8181
import definitions.findNamedMember
8282
def findMemberFromRoot(fullName: Name): Symbol = rootMirror.findMemberFromRoot(fullName)
8383
override def deferredOpenPackageModule(container: Symbol, dest: Symbol): Unit = {
84-
if (isPast(currentRun.packageobjectsPhase)) {
84+
// Some compiler runs (e.g. Toolbox and the PC) just initialise Global and then discard the Run
85+
// such that the scala package object decls never get entered into the scala package
86+
if ((curRun eq null) || !isGlobalInitialized || isPastPackageObjects) {
8587
super.openPackageModule(container, dest)
8688
} else {
8789
analyzer.packageObjects.deferredOpen(dest) = container
@@ -1023,6 +1025,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
10231025
)
10241026
override def isPastTyper = isPast(currentRun.typerPhase)
10251027
def isBeforeErasure = isBefore(currentRun.erasurePhase)
1028+
def isPastPackageObjects = isPast(currentRun.packageobjectsPhase)
10261029
def isPast(phase: Phase) = (
10271030
(curRun ne null)
10281031
&& isGlobalInitialized // defense against init order issues
@@ -1655,8 +1658,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
16551658
compileLate(new CompilationUnit(scripted(getSourceFile(file))))
16561659
}
16571660

1658-
/** Compile abstract file until `globalPhase`, but at least to phase "namer".
1659-
*/
1661+
/** Compile the unit until `globalPhase`, but at least to phase "typer". */
16601662
def compileLate(unit: CompilationUnit): Unit = {
16611663
addUnit(unit)
16621664

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,13 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
13551355
}
13561356
}
13571357

1358+
override def isPastPackageObjects = {
1359+
(if (currentTyperRun == null) NoCompilationUnit else currentTyperRun.currentUnit) match {
1360+
case unit: RichCompilationUnit => unit.isParsed
1361+
case _ => super.isPastPackageObjects
1362+
}
1363+
}
1364+
13581365
def newTyperRun(): Unit = {
13591366
currentTyperRun = new TyperRun
13601367
}

0 commit comments

Comments
 (0)
0