Skip to content

Commit 955aaf0

Browse files
committed
Finish typer
1 parent c9e3dff commit 955aaf0

13 files changed

+47
-23
lines changed

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ object Implicits:
345345
if monitored then record(s"check uncached eligible refs in irefCtx", refs.length)
346346
val ownEligible = filterMatching(tp)
347347
if isOuterMost then ownEligible
348-
else combineEligibles(ownEligible, outerImplicits.uncachedEligible(tp))
348+
else combineEligibles(ownEligible, outerImplicits.nn.uncachedEligible(tp))
349349

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

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 17 additions & 15 deletions
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._
@@ -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)

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 6 additions & 4 deletions
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
@@ -770,7 +772,7 @@ object ProtoTypes {
770772
/** Approximate occurrences of parameter types and uninstantiated typevars
771773
* by wildcard types.
772774
*/
773-
private def wildApprox(tp: Type, theMap: WildApproxMap, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = tp match {
775+
private def wildApprox(tp: Type, theMap: WildApproxMap | Null, seen: Set[TypeParamRef], internal: Set[TypeLambda])(using Context): Type = tp match {
774776
case tp: NamedType => // default case, inlined for speed
775777
val isPatternBoundTypeRef = tp.isInstanceOf[TypeRef] && tp.symbol.isPatternBound
776778
if (isPatternBoundTypeRef) WildcardType(tp.underlying.bounds)

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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)