Skip to content

Commit 66f7f95

Browse files
Use explicit nulls for reductionContext
1 parent a5195f8 commit 66f7f95

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5098,7 +5098,7 @@ object Types extends TypeUtils {
50985098
def underlying(using Context): Type = bound
50995099

51005100
private var myReduced: Type | Null = null
5101-
private var reductionContext: util.MutableMap[Type, Type] = uninitialized
5101+
private var reductionContext: util.MutableMap[Type, Type] | Null = null
51025102

51035103
override def tryNormalize(using Context): Type =
51045104
try
@@ -5153,15 +5153,12 @@ object Types extends TypeUtils {
51535153
cases.foreach(traverse)
51545154
reductionContext = util.HashMap()
51555155
for tp <- footprint do
5156-
reductionContext(tp) = contextInfo(tp)
5156+
reductionContext.nn(tp) = contextInfo(tp)
51575157
matchTypes.println(i"footprint for $thisMatchType $hashCode: ${footprint.toList.map(x => (x, contextInfo(x)))}%, %")
51585158
end setReductionContext
51595159

51605160
def changedReductionContext(): Boolean =
5161-
val isUpToDate =
5162-
(reductionContext ne null) &&
5163-
reductionContext.keysIterator.forall: tp =>
5164-
reductionContext(tp) `eq` contextInfo(tp)
5161+
val isUpToDate = reductionContext != null && reductionContext.nn.iterator.forall(contextInfo(_) `eq` _)
51655162
if !isUpToDate then setReductionContext()
51665163
!isUpToDate
51675164

@@ -5193,10 +5190,9 @@ object Types extends TypeUtils {
51935190

51945191
/** True if the reduction uses GADT constraints. */
51955192
def reducesUsingGadt(using Context): Boolean =
5196-
(reductionContext ne null) && reductionContext.keysIterator.exists {
5197-
case tp: TypeRef => reductionContext(tp).exists
5198-
case _ => false
5199-
}
5193+
reductionContext != null && reductionContext.nn.iterator.exists:
5194+
case (tp: TypeRef, tpCtx) => tpCtx.exists
5195+
case _ => false
52005196

52015197
override def computeHash(bs: Binders): Int = doHash(bs, scrutinee, bound :: cases)
52025198

0 commit comments

Comments
 (0)