From eaa3dd57f1a56151d0d6abe82f196e92aadaa843 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Wed, 13 Jun 2012 19:24:37 +0200 Subject: 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. --- src/compiler/scala/tools/nsc/Global.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') 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 -- cgit v1.2.3