@@ -375,7 +375,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
375
375
}
376
376
377
377
/* Whether the extractor is irrefutable */
378
- def irrefutable (unapp : tpd. Tree ): Boolean = {
378
+ def irrefutable (unapp : Tree ): Boolean = {
379
379
// TODO: optionless patmat
380
380
unapp.tpe.widen.finalResultType.isRef(scalaSomeClass) ||
381
381
(unapp.symbol.is(Synthetic ) && unapp.symbol.owner.linkedClass.is(Case )) ||
@@ -557,11 +557,11 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
557
557
def refine (parent : Type , child : Symbol ): Type = {
558
558
if (child.isTerm && child.is(Case , butNot = Module )) return child.termRef // enum vals always match
559
559
560
- val childTp = if (child.isTerm) child.termRef else child.typeRef
560
+ val childTp = if (child.isTerm) child.termRef else child.typeRef
561
561
562
562
val resTp = instantiate(childTp, parent)(ctx.fresh.setNewTyperState())
563
563
564
- if (! resTp.exists) {
564
+ if (! resTp.exists) {
565
565
debug.println(s " [refine] unqualified child ousted: ${childTp.show} !< ${parent.show}" )
566
566
NoType
567
567
}
@@ -625,7 +625,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
625
625
val tvars = tp1.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
626
626
val protoTp1 = thisTypeMap(tp1.appliedTo(tvars))
627
627
628
- if (protoTp1 <:< tp2) {
628
+ val result = if (protoTp1 <:< tp2) {
629
629
if (isFullyDefined(protoTp1, force)) protoTp1
630
630
else instUndetMap(protoTp1)
631
631
}
@@ -640,6 +640,24 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
640
640
NoType
641
641
}
642
642
}
643
+
644
+ // The intersection between a singleton type s and another type t is
645
+ // always empty when s is not a subtype of t. See patmat/i3573.scala
646
+ val hasEmptyIntersections = new ExistsAccumulator ({
647
+ case AndType (s : SingletonType , t) =>
648
+ ! (s <:< t)
649
+ case AndType (t, s : SingletonType ) =>
650
+ ! (s <:< t)
651
+ case x =>
652
+ false
653
+ })
654
+
655
+ if (hasEmptyIntersections(false , result)) {
656
+ debug.println(s " hasEmptyIntersections( $protoTp1) = true " )
657
+ NoType
658
+ } else {
659
+ result
660
+ }
643
661
}
644
662
645
663
/** Abstract sealed types, or-types, Boolean and Java enums can be decomposed */
0 commit comments