Skip to content

Commit aa39739

Browse files
committed
Update comments
1 parent 1958707 commit aa39739

16 files changed

+31
-45
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ object desugar {
12871287
val ts = tree.trees
12881288
val arity = ts.length
12891289
assert(arity <= Definitions.MaxTupleArity)
1290-
def tupleTypeRef = defn.TupleType(arity)
1290+
def tupleTypeRef = defn.TupleType(arity).nn
12911291
if (arity == 0)
12921292
if (ctx.mode is Mode.Type) TypeTree(defn.UnitType) else unitLiteral
12931293
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
14681468
def tupleTypeTree(elems: List[Tree])(using Context): Tree = {
14691469
val arity = elems.length
14701470
if arity <= Definitions.MaxTupleArity then
1471-
val tupleTp: TypeRef | Null = defn.TupleType(arity)
1471+
val tupleTp = defn.TupleType(arity)
14721472
if tupleTp != null then
14731473
AppliedTypeTree(TypeTree(tupleTp), elems)
14741474
else nestedPairsTypeTree(elems)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ object Annotations {
164164
object LazyBodyAnnotation {
165165
def apply(bodyFn: Context ?=> Tree): LazyBodyAnnotation =
166166
new LazyBodyAnnotation:
167-
protected var myTree: Tree | (Context ?=> Tree) = ctx ?=> bodyFn(using ctx)
167+
protected var myTree: Tree | (Context ?=> Tree) | Null = ctx ?=> bodyFn(using ctx)
168168
}
169169

170170
object Annotation {
@@ -195,15 +195,15 @@ object Annotations {
195195
/** Create an annotation where the tree is computed lazily. */
196196
def deferred(sym: Symbol)(treeFn: Context ?=> Tree)(using Context): Annotation =
197197
new LazyAnnotation {
198-
protected var myTree: Tree | (Context ?=> Tree) = ctx ?=> treeFn(using ctx)
199-
protected var mySym: Symbol | (Context ?=> Symbol) = sym
198+
protected var myTree: Tree | (Context ?=> Tree) | Null = ctx ?=> treeFn(using ctx)
199+
protected var mySym: Symbol | (Context ?=> Symbol) | Null = sym
200200
}
201201

202202
/** Create an annotation where the symbol and the tree are computed lazily. */
203203
def deferredSymAndTree(symFn: Context ?=> Symbol)(treeFn: Context ?=> Tree)(using Context): Annotation =
204204
new LazyAnnotation {
205-
protected var mySym: Symbol | (Context ?=> Symbol) = ctx ?=> symFn(using ctx)
206-
protected var myTree: Tree | (Context ?=> Tree) = ctx ?=> treeFn(using ctx)
205+
protected var mySym: Symbol | (Context ?=> Symbol) | Null = ctx ?=> symFn(using ctx)
206+
protected var myTree: Tree | (Context ?=> Tree) | Null = ctx ?=> treeFn(using ctx)
207207
}
208208

209209
/** Extractor for child annotations */

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ trait ConstraintHandling {
604604
val e = constraint.entry(param)
605605
if (e.exists) e.bounds
606606
else {
607-
// TODO
607+
// TODO: should we change the type of paramInfos to nullable?
608608
val pinfos: List[param.binder.PInfo] | Null = param.binder.paramInfos
609609
if (pinfos != null) pinfos(param.paramNum) // pinfos == null happens in pos/i536.scala
610610
else TypeBounds.empty
@@ -679,7 +679,6 @@ trait ConstraintHandling {
679679
if (!fromBelow) variance = -1
680680
def apply(t: Type): Type = t match {
681681
case t @ TypeParamRef(tl: TypeLambda, n) if comparedTypeLambdas contains tl =>
682-
// TODO: do we need to check null here?
683682
val bounds = tl.paramInfos(n)
684683
range(bounds.lo, bounds.hi)
685684
case _ =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ object Contexts {
271271
/** Either the current scope, or, if the current context owner is a class,
272272
* the declarations of the current class.
273273
*/
274+
// TODO: Should we change its type to nullable?
275+
// We can see its value can be null in nestingLevel below.
274276
def effectiveScope(using Context): Scope =
275-
// TODO
276277
val co: Symbol | Null = owner
277278
if co != null && co.isClass then co.asClass.unforcedDecls
278279
else scope
279280

280281
def nestingLevel: Int =
281-
// TODO
282282
val sc: Scope | Null = effectiveScope
283283
if sc != null then sc.nestingLevel else 0
284284

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class Definitions {
180180
private def enterT1ParameterlessMethod(cls: ClassSymbol, name: TermName, resultTypeFn: PolyType => Type, flags: FlagSet) =
181181
enterPolyMethod(cls, name, 1, resultTypeFn, flags)
182182

183-
private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[TypeRef] = {
184-
val arr = new Array[TypeRef](arity + 1)
183+
private def mkArityArray(name: String, arity: Int, countFrom: Int): Array[TypeRef | Null] = {
184+
val arr = new Array[TypeRef | Null](arity + 1)
185185
for (i <- countFrom to arity) arr(i) = requiredClassRef(name + i)
186186
arr
187187
}
@@ -1260,7 +1260,7 @@ class Definitions {
12601260

12611261
@tu lazy val untestableClasses: Set[Symbol] = Set(NothingClass, NullClass, SingletonClass)
12621262

1263-
@tu lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0)
1263+
@tu lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0).asInstanceOf[Array[TypeRef]]
12641264
val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun(AbstractFunctionType.map(_.symbol.asClass))
12651265
def AbstractFunctionClass(n: Int)(using Context): Symbol = AbstractFunctionClassPerRun()(using ctx)(n)
12661266

@@ -1283,7 +1283,7 @@ class Definitions {
12831283
.withDefaultValue(holderImpl("LazyRef"))
12841284
})
12851285

1286-
@tu lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)
1286+
@tu lazy val TupleType: Array[TypeRef | Null] = mkArityArray("scala.Tuple", MaxTupleArity, 1)
12871287

12881288
private class FunType(prefix: String):
12891289
private var classRefs: Array[TypeRef | Null] = new Array(22)
@@ -1497,15 +1497,15 @@ class Definitions {
14971497
def isTupleNType(tp: Type)(using Context): Boolean = {
14981498
val arity = tp.dealias.argInfos.length
14991499
arity <= MaxTupleArity && {
1500-
val tupletp: TypeRef | Null = TupleType(arity)
1500+
val tupletp = TupleType(arity)
15011501
tupletp != null && tp.isRef(tupletp.symbol)
15021502
}
15031503
}
15041504

15051505
def tupleType(elems: List[Type]): Type = {
15061506
val arity = elems.length
15071507
if 0 < arity && arity <= MaxTupleArity then
1508-
val tupletp: TypeRef | Null = TupleType(arity)
1508+
val tupletp = TupleType(arity)
15091509
if tupletp != null then tupletp.appliedTo(elems)
15101510
else TypeOps.nestedPairs(elems)
15111511
else TypeOps.nestedPairs(elems)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object TypeErasure {
132132
*/
133133
abstract case class ErasedValueType(tycon: TypeRef, erasedUnderlying: Type)
134134
extends CachedGroundType with ValueType {
135-
override def computeHash(bs: Hashable.Binders): Int = doHash(bs, tycon, erasedUnderlying)
135+
override def computeHash(bs: Hashable.Binders | Null): Int = doHash(bs, tycon, erasedUnderlying)
136136
}
137137

138138
final class CachedErasedValueType(tycon: TypeRef, erasedUnderlying: Type)
@@ -690,7 +690,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
690690
private def erasePair(tp: Type)(using Context): Type = {
691691
val arity = tp.tupleArity
692692
if (arity < 0) defn.ProductClass.typeRef
693-
else if (arity <= Definitions.MaxTupleArity) defn.TupleType(arity)
693+
else if (arity <= Definitions.MaxTupleArity) defn.TupleType(arity).nn
694694
else defn.TupleXXLClass.typeRef
695695
}
696696

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3919,7 +3919,6 @@ object Types {
39193919
&& {
39203920
val bs1 = new BinderPairs(this, that, bs)
39213921
// `paramInfos` and `resType` might still be uninstantiated at this point
3922-
// TODO:
39233922
(paramInfos: List[TypeBounds] | Null) != null && (resType: Type | Null) != null &&
39243923
paramInfos.equalElements(that.paramInfos, bs1) &&
39253924
resType.equals(that.resType, bs1)

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ class PatternMatcher extends MiniPhase {
4646
case rt => tree.tpe
4747
val translated = new Translator(matchType, this).translateMatch(tree)
4848

49-
val engineCtx =
50-
if tree.hasAttachment(Nullables.UnsafeNullsMatch)
51-
then ctx.retractMode(Mode.SafeNulls) else ctx
52-
5349
// check exhaustivity and unreachability
54-
val engine = new patmat.SpaceEngine()(using engineCtx)
50+
val engine = new patmat.SpaceEngine
5551
engine.checkExhaustivity(tree)
5652
engine.checkRedundancy(tree)
5753

compiler/src/dotty/tools/dotc/transform/TupleOptimizations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TupleOptimizations extends MiniPhase with IdentityDenotTransformer {
195195
private def knownTupleFromElements(tpes: List[Type], elements: List[Tree])(using Context) = {
196196
val size = elements.size
197197
assert(0 < size && size <= MaxTupleArity)
198-
val tupleModule = defn.TupleType(size).classSymbol.companionModule
198+
val tupleModule = defn.TupleType(size).nn.classSymbol.companionModule
199199
ref(tupleModule).select(nme.apply).appliedToTypes(tpes).appliedToTermArgs(elements)
200200
}
201201

0 commit comments

Comments
 (0)