@@ -2,6 +2,8 @@ package dotty.tools
2
2
package dotc
3
3
package typer
4
4
5
+ import scala .language .{unsafeNulls => _ }
6
+
5
7
import core ._
6
8
import ast ._
7
9
import Trees ._ , StdNames ._ , Scopes ._ , Denotations ._ , NamerOps ._ , ContextOps ._
@@ -531,7 +533,7 @@ class Namer { typer: Typer =>
531
533
* body and derived clause of the synthetic module class `fromCls`.
532
534
*/
533
535
def mergeModuleClass (mdef : Tree , modCls : TypeDef , fromCls : TypeDef ): TypeDef = {
534
- var res : TypeDef = null
536
+ var res : TypeDef | Null = null
535
537
val Thicket (trees) = expanded(mdef)
536
538
val merged = trees.map { tree =>
537
539
if (tree == modCls) {
@@ -544,16 +546,16 @@ class Namer { typer: Typer =>
544
546
if (fromTempl.derived.nonEmpty) {
545
547
if (modTempl.derived.nonEmpty)
546
548
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)
548
550
}
549
- res
551
+ res.uncheckedNN
550
552
}
551
553
else tree
552
554
}
553
555
554
556
mdef.putAttachment(ExpandedTree , Thicket (merged))
555
557
556
- res
558
+ res.nn
557
559
}
558
560
559
561
/** Merge `fromCls` of `fromStat` into `toCls` of `toStat`
@@ -766,7 +768,7 @@ class Namer { typer: Typer =>
766
768
if (Config .showCompletions && ctx.typerState != creationContext.typerState) {
767
769
def levels (c : Context ): Int =
768
770
if (c.typerState eq creationContext.typerState) 0
769
- else if (c.typerState == null ) - 1
771
+ else if (( c.typerState: TyperState | Null ) == null ) - 1
770
772
else if (c.outer.typerState == c.typerState) levels(c.outer)
771
773
else levels(c.outer) + 1
772
774
println(s " !!!completing ${denot.symbol.showLocated} in buried typerState, gap = ${levels(ctx)}" )
@@ -786,13 +788,13 @@ class Namer { typer: Typer =>
786
788
completer.complete(denot)
787
789
}
788
790
789
- private var completedTypeParamSyms : List [TypeSymbol ] = null
791
+ private var completedTypeParamSyms : List [TypeSymbol ] | Null = null
790
792
791
793
def setCompletedTypeParams (tparams : List [TypeSymbol ]) =
792
794
completedTypeParamSyms = tparams
793
795
794
796
override def completerTypeParams (sym : Symbol )(using Context ): List [TypeSymbol ] =
795
- if completedTypeParamSyms != null then completedTypeParamSyms
797
+ if completedTypeParamSyms != null then completedTypeParamSyms.uncheckedNN
796
798
else Nil
797
799
798
800
protected def addAnnotations (sym : Symbol ): Unit = original match {
@@ -894,8 +896,8 @@ class Namer { typer: Typer =>
894
896
895
897
class TypeDefCompleter (original : TypeDef )(ictx : Context )
896
898
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
899
901
assert(! original.isClassDef)
900
902
901
903
/** If completion of the owner of the to be completed symbol has not yet started,
@@ -916,7 +918,7 @@ class Namer { typer: Typer =>
916
918
if myTypeParams == null then
917
919
// println(i"completing type params of $sym in ${sym.owner}")
918
920
nestedCtx = localContext(sym).setNewScope
919
- given Context = nestedCtx
921
+ given Context = nestedCtx.uncheckedNN
920
922
921
923
def typeParamTrees (tdef : Tree ): List [TypeDef ] = tdef match
922
924
case TypeDef (_, original) =>
@@ -931,12 +933,12 @@ class Namer { typer: Typer =>
931
933
myTypeParams = tparams.map(symbolOfTree(_).asType)
932
934
for param <- tparams do typedAheadExpr(param)
933
935
end if
934
- myTypeParams
936
+ myTypeParams.uncheckedNN
935
937
end completerTypeParams
936
938
937
939
override final def typeSig (sym : Symbol ): Type =
938
940
val tparamSyms = completerTypeParams(sym)(using ictx)
939
- given ctx : Context = nestedCtx
941
+ given ctx : Context = nestedCtx.nn
940
942
941
943
def abstracted (tp : TypeBounds ): TypeBounds =
942
944
HKTypeLambda .boundsFromParams(tparamSyms, tp)
@@ -1025,7 +1027,7 @@ class Namer { typer: Typer =>
1025
1027
private var localCtx : Context = _
1026
1028
1027
1029
/** 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
1029
1031
1030
1032
val TypeDef (name, impl @ Template (constr, _, self, _)) = original
1031
1033
@@ -1358,7 +1360,7 @@ class Namer { typer: Typer =>
1358
1360
end addUsingTraits
1359
1361
1360
1362
completeConstructor(denot)
1361
- denot.info = tempInfo
1363
+ denot.info = tempInfo.nn
1362
1364
1363
1365
val parentTypes = defn.adjustForTuple(cls, cls.typeParams,
1364
1366
defn.adjustForBoxedUnit(cls,
@@ -1379,7 +1381,7 @@ class Namer { typer: Typer =>
1379
1381
original.putAttachment(AttachedDeriver , deriver)
1380
1382
}
1381
1383
1382
- denot.info = tempInfo.finalized(parentTypes)
1384
+ denot.info = tempInfo.nn. finalized(parentTypes)
1383
1385
tempInfo = null // The temporary info can now be garbage-collected
1384
1386
1385
1387
Checking .checkWellFormed(cls)
0 commit comments