@@ -2,6 +2,8 @@ package dotty.tools
22package dotc
33package typer
44
5+ import scala .language .{unsafeNulls => _ }
6+
57import core ._
68import ast ._
79import Trees ._ , StdNames ._ , Scopes ._ , Denotations ._ , NamerOps ._ , ContextOps ._
@@ -528,7 +530,7 @@ class Namer { typer: Typer =>
528530 * body and derived clause of the synthetic module class `fromCls`.
529531 */
530532 def mergeModuleClass (mdef : Tree , modCls : TypeDef , fromCls : TypeDef ): TypeDef = {
531- var res : TypeDef = null
533+ var res : TypeDef | Null = null
532534 val Thicket (trees) = expanded(mdef)
533535 val merged = trees.map { tree =>
534536 if (tree == modCls) {
@@ -541,16 +543,16 @@ class Namer { typer: Typer =>
541543 if (fromTempl.derived.nonEmpty) {
542544 if (modTempl.derived.nonEmpty)
543545 report.error(em " a class and its companion cannot both have `derives` clauses " , mdef.srcPos)
544- res.putAttachment(desugar.DerivingCompanion , fromTempl.srcPos.startPos)
546+ res.uncheckedNN. putAttachment(desugar.DerivingCompanion , fromTempl.srcPos.startPos)
545547 }
546- res
548+ res.uncheckedNN
547549 }
548550 else tree
549551 }
550552
551553 mdef.putAttachment(ExpandedTree , Thicket (merged))
552554
553- res
555+ res.nn
554556 }
555557
556558 /** Merge `fromCls` of `fromStat` into `toCls` of `toStat`
@@ -792,7 +794,7 @@ class Namer { typer: Typer =>
792794 if (Config .showCompletions && ctx.typerState != creationContext.typerState) {
793795 def levels (c : Context ): Int =
794796 if (c.typerState eq creationContext.typerState) 0
795- else if (c.typerState == null ) - 1
797+ else if (( c.typerState: TyperState | Null ) == null ) - 1
796798 else if (c.outer.typerState == c.typerState) levels(c.outer)
797799 else levels(c.outer) + 1
798800 println(s " !!!completing ${denot.symbol.showLocated} in buried typerState, gap = ${levels(ctx)}" )
@@ -812,13 +814,13 @@ class Namer { typer: Typer =>
812814 completer.complete(denot)
813815 }
814816
815- private var completedTypeParamSyms : List [TypeSymbol ] = null
817+ private var completedTypeParamSyms : List [TypeSymbol ] | Null = null
816818
817819 def setCompletedTypeParams (tparams : List [TypeSymbol ]) =
818820 completedTypeParamSyms = tparams
819821
820822 override def completerTypeParams (sym : Symbol )(using Context ): List [TypeSymbol ] =
821- if completedTypeParamSyms != null then completedTypeParamSyms
823+ if completedTypeParamSyms != null then completedTypeParamSyms.uncheckedNN
822824 else Nil
823825
824826 protected def addAnnotations (sym : Symbol ): Unit = original match {
@@ -920,8 +922,8 @@ class Namer { typer: Typer =>
920922
921923 class TypeDefCompleter (original : TypeDef )(ictx : Context )
922924 extends Completer (original)(ictx) with TypeParamsCompleter {
923- private var myTypeParams : List [TypeSymbol ] = null
924- private var nestedCtx : Context = null
925+ private var myTypeParams : List [TypeSymbol ] | Null = null
926+ private var nestedCtx : Context | Null = null
925927 assert(! original.isClassDef)
926928
927929 /** If completion of the owner of the to be completed symbol has not yet started,
@@ -942,7 +944,7 @@ class Namer { typer: Typer =>
942944 if myTypeParams == null then
943945 // println(i"completing type params of $sym in ${sym.owner}")
944946 nestedCtx = localContext(sym).setNewScope
945- given Context = nestedCtx
947+ given Context = nestedCtx.uncheckedNN
946948
947949 def typeParamTrees (tdef : Tree ): List [TypeDef ] = tdef match
948950 case TypeDef (_, original) =>
@@ -957,12 +959,12 @@ class Namer { typer: Typer =>
957959 myTypeParams = tparams.map(symbolOfTree(_).asType)
958960 for param <- tparams do typedAheadExpr(param)
959961 end if
960- myTypeParams
962+ myTypeParams.uncheckedNN
961963 end completerTypeParams
962964
963965 override final def typeSig (sym : Symbol ): Type =
964966 val tparamSyms = completerTypeParams(sym)(using ictx)
965- given ctx : Context = nestedCtx
967+ given ctx : Context = nestedCtx.nn
966968
967969 def abstracted (tp : TypeBounds ): TypeBounds =
968970 HKTypeLambda .boundsFromParams(tparamSyms, tp)
@@ -1051,7 +1053,7 @@ class Namer { typer: Typer =>
10511053 private var localCtx : Context = _
10521054
10531055 /** info to be used temporarily while completing the class, to avoid cyclic references. */
1054- private var tempInfo : TempClassInfo = _
1056+ private var tempInfo : TempClassInfo | Null = null
10551057
10561058 val TypeDef (name, impl @ Template (constr, _, self, _)) = original
10571059
@@ -1401,7 +1403,7 @@ class Namer { typer: Typer =>
14011403 end addUsingTraits
14021404
14031405 completeConstructor(denot)
1404- denot.info = tempInfo
1406+ denot.info = tempInfo.nn
14051407
14061408 val parentTypes = defn.adjustForTuple(cls, cls.typeParams,
14071409 defn.adjustForBoxedUnit(cls,
@@ -1422,7 +1424,7 @@ class Namer { typer: Typer =>
14221424 original.putAttachment(AttachedDeriver , deriver)
14231425 }
14241426
1425- denot.info = tempInfo.finalized(parentTypes)
1427+ denot.info = tempInfo.nn. finalized(parentTypes)
14261428 tempInfo = null // The temporary info can now be garbage-collected
14271429
14281430 Checking .checkWellFormed(cls)
0 commit comments