diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-31 08:26:18 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-31 08:49:56 -0700 |
commit | 1e1199d8abbd81ab2fa3b9cbab0290d6793e0945 (patch) | |
tree | bde1e98d0f4a060d14e6ce681366d82f533d0ceb /src/compiler/scala/tools/nsc/Global.scala | |
parent | b480d991072e6e68ed46574d87e4483da778ff0e (diff) | |
download | scala-1e1199d8abbd81ab2fa3b9cbab0290d6793e0945.tar.gz scala-1e1199d8abbd81ab2fa3b9cbab0290d6793e0945.tar.bz2 scala-1e1199d8abbd81ab2fa3b9cbab0290d6793e0945.zip |
Fix for -Xcheckinit failures.
The GenASM phase had an eager val which required loading
a bunch of symbols, which meant an earlier call to isPastTyper
could lead to a cycle of the form:
new Run
new GenASM
rootMirror.getRequiredClass
findMember
defineBaseClassesOfCompoundType
isPastTyper
currentRun.typerPhase
and the opening "new Run" hasn't yet caught up to where
currentRun.typerPhase is set.
This was remedied by making the eager val lazy, and
substantially hardened against recurrence via a method on
global "isGlobalInitialized" which verifies that both
the definitions object and the root mirror have completed
their init methods.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 40a14aec6f..5b5cffa885 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1046,9 +1046,13 @@ class Global(var currentSettings: Settings, var reporter: Reporter) def currentUnit: CompilationUnit = if (currentRun eq null) NoCompilationUnit else currentRun.currentUnit def currentSource: SourceFile = if (currentUnit.exists) currentUnit.source else lastSeenSourceFile + def isGlobalInitialized = ( + definitions.isDefinitionsInitialized + && rootMirror.isMirrorInitialized + ) override def isPastTyper = ( (curRun ne null) - && (currentRun.typerPhase ne null) + && isGlobalInitialized // defense against init order issues && (globalPhase.id > currentRun.typerPhase.id) ) @@ -1525,9 +1529,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) def compileUnits(units: List[CompilationUnit], fromPhase: Phase) { try compileUnitsInternal(units, fromPhase) catch { case ex: Throwable => - val shown = if (settings.verbose.value) + val shown = if (settings.verbose.value) stackTraceString(ex) - else + else ex.getClass.getName // ex.printStackTrace(Console.out) // DEBUG for fsc, note that error stacktraces do not print in fsc globalError(supplementErrorMessage("uncaught exception during compilation: " + shown)) |