File tree 1 file changed +13
-8
lines changed
compiler/src/dotty/tools/dotc/transform/patmat 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -294,16 +294,21 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
294
294
295
295
override def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type ) = {
296
296
val and = AndType (tp1, tp2)
297
- // Precondition: !(tp1 <:< tp2) && !(tp2 <:< tp1)
298
- // Then, no leaf of the and-type tree `and` is a subtype of `and`.
299
- val res = inhabited(and)
297
+ // Precondition: !isSubType(tp1, tp2) && !isSubType(tp2 <:< tp1)
298
+ if (tp1 == nullType || tp2 == nullType) {
299
+ // Since projections of types don't include null, intersection with null is empty.
300
+ Empty
301
+ } else {
302
+ // Then, no leaf of the and-type tree `and` is a subtype of `and`.
303
+ val res = inhabited(and)
300
304
301
- debug.println(s " atomic intersection: ${and.show} = ${res}" )
305
+ debug.println(s " atomic intersection: ${and.show} = ${res}" )
302
306
303
- if (! res) Empty
304
- else if (tp1.isSingleton) Typ (tp1, true )
305
- else if (tp2.isSingleton) Typ (tp2, true )
306
- else Typ (and, true )
307
+ if (! res) Empty
308
+ else if (tp1.isSingleton) Typ (tp1, true )
309
+ else if (tp2.isSingleton) Typ (tp2, true )
310
+ else Typ (and, true )
311
+ }
307
312
}
308
313
309
314
/** Whether the extractor is irrefutable */
You can’t perform that action at this time.
0 commit comments