@@ -1172,24 +1172,28 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1172
1172
else None
1173
1173
}
1174
1174
1175
- /** Check whether we can compare the given set of atoms with another to determine
1176
- * a subtype test between OrTypes. There is one situation where this is not
1177
- * the case, which has to do with SkolemTypes. TreeChecker sometimes expects two
1178
- * types to be equal that have different skolems. To account for this, we identify
1179
- * two different skolems in all phases `p`, where `p.isTyper` is false.
1180
- * But in that case comparing two sets of atoms that contain skolems
1181
- * for equality would give the wrong result, so we should not use the sets
1182
- * for comparisons.
1175
+ /** If both `tp1` and `tp2` have atoms information, compare the atoms
1176
+ * in a Some, otherwise None.
1183
1177
*/
1184
1178
def compareAtoms (tp1 : Type , tp2 : Type ): Option [Boolean ] =
1179
+
1180
+ /** Check whether we can compare the given set of atoms with another to determine
1181
+ * a subtype test between OrTypes. There is one situation where this is not
1182
+ * the case, which has to do with SkolemTypes. TreeChecker sometimes expects two
1183
+ * types to be equal that have different skolems. To account for this, we identify
1184
+ * two different skolems in all phases `p`, where `p.isTyper` is false.
1185
+ * But in that case comparing two sets of atoms that contain skolems
1186
+ * for equality would give the wrong result, so we should not use the sets
1187
+ * for comparisons.
1188
+ */
1185
1189
def canCompare (ts : Set [Type ]) = ctx.phase.isTyper || {
1186
1190
val hasSkolems = new ExistsAccumulator (_.isInstanceOf [SkolemType ]) {
1187
1191
override def stopAtStatic = true
1188
1192
}
1189
1193
! ts.exists(hasSkolems(false , _))
1190
1194
}
1191
1195
def verified (result : Boolean ): Boolean =
1192
- if Config .checkAtomsComparisons && false then
1196
+ if Config .checkAtomsComparisons then
1193
1197
try
1194
1198
canCompareAtoms = false
1195
1199
val regular = recur(tp1, tp2)
@@ -1201,16 +1205,14 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1201
1205
finally canCompareAtoms = true
1202
1206
result
1203
1207
1204
- def falseUnlessBottom = Some (verified(recur(tp1, NothingType )))
1205
-
1206
1208
tp2.atoms match
1207
1209
case Atoms .Range (lo2, hi2) if canCompareAtoms && canCompare(hi2) =>
1208
1210
tp1.atoms match
1209
1211
case Atoms .Range (lo1, hi1) =>
1210
1212
if hi1.subsetOf(lo2) then Some (verified(true ))
1211
- else if ! lo1.subsetOf(hi2) then falseUnlessBottom
1213
+ else if ! lo1.subsetOf(hi2) then Some (verified( false ))
1212
1214
else None
1213
- case _ => falseUnlessBottom
1215
+ case _ => Some (verified(recur(tp1, NothingType )))
1214
1216
case _ => None
1215
1217
1216
1218
/** Subtype test for corresponding arguments in `args1`, `args2` according to
0 commit comments