diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2012-06-13 19:24:37 +0200 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2012-06-13 19:24:37 +0200 |
commit | eaa3dd57f1a56151d0d6abe82f196e92aadaa843 (patch) | |
tree | 40ae877895b7aaff30e3a074f10f9464898d3181 | |
parent | f4d2678c42a82a2716eac8bc50e39a1d96fb67c0 (diff) | |
download | scala-eaa3dd57f1a56151d0d6abe82f196e92aadaa843.tar.gz scala-eaa3dd57f1a56151d0d6abe82f196e92aadaa843.tar.bz2 scala-eaa3dd57f1a56151d0d6abe82f196e92aadaa843.zip |
Remove NPE when `compileLate` sees sources during initialization.
When a symbol needed in Definitions is loaded, it may be that the corresponding source is newer than
the classfile. That will send it to `compileLate`, but no phase is yet set. We simply add it to the
compilation pipeline and continue gracefully.
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 787c9c7f57..a701e41153 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1667,13 +1667,14 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Compile abstract file until `globalPhase`, but at least to phase "namer". */ def compileLate(unit: CompilationUnit) { - val maxId = math.max(globalPhase.id, typerPhase.id) addUnit(unit) - firstPhase.iterator takeWhile (_.id < maxId) foreach (ph => - atPhase(ph)(ph.asInstanceOf[GlobalPhase] applyPhase unit) - ) - refreshProgress + if (firstPhase ne null) { // we might get here during initialization, is a source is newer than the binary + val maxId = math.max(globalPhase.id, typerPhase.id) + firstPhase.iterator takeWhile (_.id < maxId) foreach (ph => + atPhase(ph)(ph.asInstanceOf[GlobalPhase] applyPhase unit)) + refreshProgress + } } /** Reset package class to state at typer (not sure what this |