@@ -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 ._
@@ -531,7 +533,7 @@ class Namer { typer: Typer =>
531533 * body and derived clause of the synthetic module class `fromCls`.
532534 */
533535 def mergeModuleClass (mdef : Tree , modCls : TypeDef , fromCls : TypeDef ): TypeDef = {
534- var res : TypeDef = null
536+ var res : TypeDef | Null = null
535537 val Thicket (trees) = expanded(mdef)
536538 val merged = trees.map { tree =>
537539 if (tree == modCls) {
@@ -544,16 +546,16 @@ class Namer { typer: Typer =>
544546 if (fromTempl.derived.nonEmpty) {
545547 if (modTempl.derived.nonEmpty)
546548 report.error(em " a class and its companion cannot both have `derives` clauses " , mdef.srcPos)
547- res.putAttachment(desugar.DerivingCompanion , fromTempl.srcPos.startPos)
549+ res.uncheckedNN. putAttachment(desugar.DerivingCompanion , fromTempl.srcPos.startPos)
548550 }
549- res
551+ res.uncheckedNN
550552 }
551553 else tree
552554 }
553555
554556 mdef.putAttachment(ExpandedTree , Thicket (merged))
555557
556- res
558+ res.nn
557559 }
558560
559561 /** Merge `fromCls` of `fromStat` into `toCls` of `toStat`
@@ -766,7 +768,7 @@ class Namer { typer: Typer =>
766768 if (Config .showCompletions && ctx.typerState != creationContext.typerState) {
767769 def levels (c : Context ): Int =
768770 if (c.typerState eq creationContext.typerState) 0
769- else if (c.typerState == null ) - 1
771+ else if (( c.typerState: TyperState | Null ) == null ) - 1
770772 else if (c.outer.typerState == c.typerState) levels(c.outer)
771773 else levels(c.outer) + 1
772774 println(s " !!!completing ${denot.symbol.showLocated} in buried typerState, gap = ${levels(ctx)}" )
@@ -786,13 +788,13 @@ class Namer { typer: Typer =>
786788 completer.complete(denot)
787789 }
788790
789- private var completedTypeParamSyms : List [TypeSymbol ] = null
791+ private var completedTypeParamSyms : List [TypeSymbol ] | Null = null
790792
791793 def setCompletedTypeParams (tparams : List [TypeSymbol ]) =
792794 completedTypeParamSyms = tparams
793795
794796 override def completerTypeParams (sym : Symbol )(using Context ): List [TypeSymbol ] =
795- if completedTypeParamSyms != null then completedTypeParamSyms
797+ if completedTypeParamSyms != null then completedTypeParamSyms.uncheckedNN
796798 else Nil
797799
798800 protected def addAnnotations (sym : Symbol ): Unit = original match {
@@ -894,8 +896,8 @@ class Namer { typer: Typer =>
894896
895897 class TypeDefCompleter (original : TypeDef )(ictx : Context )
896898 extends Completer (original)(ictx) with TypeParamsCompleter {
897- private var myTypeParams : List [TypeSymbol ] = null
898- private var nestedCtx : Context = null
899+ private var myTypeParams : List [TypeSymbol ] | Null = null
900+ private var nestedCtx : Context | Null = null
899901 assert(! original.isClassDef)
900902
901903 /** If completion of the owner of the to be completed symbol has not yet started,
@@ -916,7 +918,7 @@ class Namer { typer: Typer =>
916918 if myTypeParams == null then
917919 // println(i"completing type params of $sym in ${sym.owner}")
918920 nestedCtx = localContext(sym).setNewScope
919- given Context = nestedCtx
921+ given Context = nestedCtx.uncheckedNN
920922
921923 def typeParamTrees (tdef : Tree ): List [TypeDef ] = tdef match
922924 case TypeDef (_, original) =>
@@ -931,12 +933,12 @@ class Namer { typer: Typer =>
931933 myTypeParams = tparams.map(symbolOfTree(_).asType)
932934 for param <- tparams do typedAheadExpr(param)
933935 end if
934- myTypeParams
936+ myTypeParams.uncheckedNN
935937 end completerTypeParams
936938
937939 override final def typeSig (sym : Symbol ): Type =
938940 val tparamSyms = completerTypeParams(sym)(using ictx)
939- given ctx : Context = nestedCtx
941+ given ctx : Context = nestedCtx.nn
940942
941943 def abstracted (tp : TypeBounds ): TypeBounds =
942944 HKTypeLambda .boundsFromParams(tparamSyms, tp)
@@ -1025,7 +1027,7 @@ class Namer { typer: Typer =>
10251027 private var localCtx : Context = _
10261028
10271029 /** info to be used temporarily while completing the class, to avoid cyclic references. */
1028- private var tempInfo : TempClassInfo = _
1030+ private var tempInfo : TempClassInfo | Null = null
10291031
10301032 val TypeDef (name, impl @ Template (constr, _, self, _)) = original
10311033
@@ -1358,7 +1360,7 @@ class Namer { typer: Typer =>
13581360 end addUsingTraits
13591361
13601362 completeConstructor(denot)
1361- denot.info = tempInfo
1363+ denot.info = tempInfo.nn
13621364
13631365 val parentTypes = defn.adjustForTuple(cls, cls.typeParams,
13641366 defn.adjustForBoxedUnit(cls,
@@ -1379,7 +1381,7 @@ class Namer { typer: Typer =>
13791381 original.putAttachment(AttachedDeriver , deriver)
13801382 }
13811383
1382- denot.info = tempInfo.finalized(parentTypes)
1384+ denot.info = tempInfo.nn. finalized(parentTypes)
13831385 tempInfo = null // The temporary info can now be garbage-collected
13841386
13851387 Checking .checkWellFormed(cls)
0 commit comments