@@ -349,8 +349,7 @@ object Contexts {
349349 if ctx1 == null then
350350 util.Stats .record(" Context.withSource.new" )
351351 val ctx2 = fresh.setSource(source)
352- val ctx2unit : CompilationUnit | Null = ctx2.compilationUnit
353- if ctx2unit == null then
352+ if ctx2.compilationUnit eq NoCompilationUnit then
354353 // `source` might correspond to a file not necessarily
355354 // in the current project (e.g. when inlining library code),
356355 // so set `mustExist` to false.
@@ -394,12 +393,7 @@ object Contexts {
394393 final def erasedTypes = phase.erasedTypes
395394
396395 /** Are we in a Java compilation unit? */
397- final def isJava : Boolean =
398- // FIXME: It would be much nicer if compilationUnit was non-nullable,
399- // perhaps we need to introduce a `NoCompilationUnit` compilation unit
400- // to be used as a default value.
401- val unit : CompilationUnit | Null = compilationUnit
402- unit != null && unit.isJava
396+ final def isJava : Boolean = compilationUnit.isJava
403397
404398 /** Is current phase after TyperPhase? */
405399 final def isAfterTyper = base.isAfterTyper(phase)
@@ -837,6 +831,7 @@ object Contexts {
837831 store = initialStore
838832 .updated(settingsStateLoc, settingsGroup.defaultState)
839833 .updated(notNullInfosLoc, Nil )
834+ .updated(compilationUnitLoc, NoCompilationUnit )
840835 searchHistory = new SearchRoot
841836 gadt = EmptyGadtConstraint
842837 }
0 commit comments