File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed
compiler/src/dotty/tools/dotc/transform/patmat Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -294,16 +294,21 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
294294
295295 override def intersectUnrelatedAtomicTypes (tp1 : Type , tp2 : Type ) = {
296296 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)
300304
301- debug.println(s " atomic intersection: ${and.show} = ${res}" )
305+ debug.println(s " atomic intersection: ${and.show} = ${res}" )
302306
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+ }
307312 }
308313
309314 /** Whether the extractor is irrefutable */
Original file line number Diff line number Diff line change 1+ 9: Match case Unreachable
2+ 10: Match case Unreachable
3+ 11: Match case Unreachable
Original file line number Diff line number Diff line change 1+ trait Foo
2+ class One extends Foo
3+ class Two extends Foo
4+ class Three extends Foo
5+
6+ object Test {
7+ def test (f : Foo ) = f match {
8+ case f : Foo =>
9+ case f : One =>
10+ case f : Two =>
11+ case f : Three =>
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments