Skip to content

Commit 319e445

Browse files
committed
Finish typer
1 parent db7d2c4 commit 319e445

13 files changed

+47
-23
lines changed

compiler/src/dotty/tools/dotc/core/Names.scala

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package core
44

5+
// import scala.language.{unsafeNulls => _}
6+
57
import scala.io.Codec
68
import util.NameTransformer
79
import printing.{Showable, Texts, Printer}

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ object Implicits:
344344
if monitored then record(s"check uncached eligible refs in irefCtx", refs.length)
345345
val ownEligible = filterMatching(tp)
346346
if isOuterMost then ownEligible
347-
else combineEligibles(ownEligible, outerImplicits.uncachedEligible(tp))
347+
else combineEligibles(ownEligible, outerImplicits.nn.uncachedEligible(tp))
348348

349349
/** The implicit references that are eligible for type `tp`. */
350350
def eligible(tp: Type): List[Candidate] =

compiler/src/dotty/tools/dotc/typer/JavaChecks.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dotty.tools.dotc
22
package typer
33

4+
import scala.language.{unsafeNulls => _}
5+
46
import core.Contexts._
57
import ast.tpd._
68

compiler/src/dotty/tools/dotc/typer/Namer.scala

+17-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import core._
68
import ast._
79
import 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)

compiler/src/dotty/tools/dotc/typer/PrepareInlineable.scala

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import dotty.tools.dotc.ast.{Trees, tpd, untpd}
68
import Trees._
79
import core._

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import core._
68
import ast._
79
import Contexts._, Types._, Denotations._, Names._, StdNames._, NameOps._, Symbols._
@@ -357,10 +359,10 @@ object ProtoTypes {
357359
targ = arg.withType(WildcardType)
358360
case _ =>
359361
targ = typerFn(arg)
360-
if (!ctx.reporter.hasUnreportedErrors)
361-
state.typedArg = state.typedArg.updated(arg, targ)
362+
if (!ctx.reporter.hasUnreportedErrors && targ != null)
363+
state.typedArg = state.typedArg.updated(arg, targ.uncheckedNN)
362364
}
363-
targ
365+
targ.nn
364366
}
365367

366368
/** The typed arguments. This takes any arguments already typed using
@@ -760,7 +762,7 @@ object ProtoTypes {
760762
/** Approximate occurrences of parameter types and uninstantiated typevars
761763
* by wildcard types.
762764
*/
763-
private def wildApprox(tp: Type, theMap: WildApproxMap, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = tp match {
765+
private def wildApprox(tp: Type, theMap: WildApproxMap | Null, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = tp match {
764766
case tp: NamedType => // default case, inlined for speed
765767
val isPatternBoundTypeRef = tp.isInstanceOf[TypeRef] && tp.symbol.isPatternBound
766768
if (isPatternBoundTypeRef) WildcardType(tp.underlying.bounds)

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dotty.tools.dotc
22
package typer
33

4+
import scala.language.{unsafeNulls => _}
5+
46
import dotty.tools.dotc.ast._
57
import dotty.tools.dotc.ast.Trees._
68
import dotty.tools.dotc.config.Feature._

compiler/src/dotty/tools/dotc/typer/ReTyper.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dotty.tools.dotc
22
package typer
33

4+
import scala.language.{unsafeNulls => _}
5+
46
import core._
57
import Contexts._
68
import Types._

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import transform._
68
import core._
79
import Symbols._, Types._, Contexts._, Flags._, Names._, NameOps._, NameKinds._
@@ -981,7 +983,7 @@ object RefChecks {
981983
val msg = annot.argumentConstant(0).get.stringValue
982984
report.warning(SymbolChangedSemanticsInVersion(sym, symVersion, msg), pos)
983985
case Failure(ex) =>
984-
report.warning(SymbolHasUnparsableVersionNumber(sym, ex.getMessage), pos)
986+
report.warning(SymbolHasUnparsableVersionNumber(sym, ex.getMessage.nn), pos)
985987
case _ =>
986988

987989
/** Check that a deprecated val or def does not override a
@@ -1182,9 +1184,9 @@ object RefChecks {
11821184
val matches = referencePattern.findAllIn(s)
11831185
for reference <- matches do
11841186
val referenceOffset = matches.start
1185-
val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "")
1187+
val prefixlessReference = reference.replaceFirst("""\$\{\s*""", "").nn
11861188
val variableOffset = referenceOffset + reference.length - prefixlessReference.length
1187-
val variableName = prefixlessReference.replaceFirst("""\s*\}""", "")
1189+
val variableName = prefixlessReference.replaceFirst("""\s*\}""", "").nn
11881190
f(variableName, variableOffset)
11891191

11901192
end checkImplicitNotFoundAnnotation

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import core._
68
import util.Spans.Span
79
import Contexts._

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import core._
68
import ast._
79
import Contexts._, ContextOps._, Constants._, Types._, Symbols._, Names._, Flags._, Decorators._

compiler/src/dotty/tools/dotc/typer/TyperPhase.scala

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty.tools
22
package dotc
33
package typer
44

5+
import scala.language.{unsafeNulls => _}
6+
57
import core._
68
import Phases._
79
import Contexts._

compiler/src/dotty/tools/dotc/typer/VarianceChecker.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dotty.tools.dotc
22
package typer
33

4+
import scala.language.{unsafeNulls => _}
5+
46
import dotty.tools.dotc.ast.{ Trees, tpd }
57
import core._
68
import Types._, Contexts._, Flags._, Symbols._, Trees._

0 commit comments

Comments
 (0)