Skip to content

Fix #9016: Fix stackoverflows in provablyDisjoint #9017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2413,13 +2413,12 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
provablyDisjoint(tp1.tp1, tp2) && provablyDisjoint(tp1.tp2, tp2)
case (_, tp2: OrType) =>
provablyDisjoint(tp1, tp2.tp1) && provablyDisjoint(tp1, tp2.tp2)
case (tp1: AndType, tp2: AndType) =>
(provablyDisjoint(tp1.tp1, tp2.tp1) || provablyDisjoint(tp1.tp2, tp2.tp2)) &&
(provablyDisjoint(tp1.tp1, tp2.tp2) || provablyDisjoint(tp1.tp2, tp2.tp1))
case (tp1: AndType, _) =>
provablyDisjoint(tp1.tp2, tp2) || provablyDisjoint(tp1.tp1, tp2)
!(tp1 <:< tp2)
&& (provablyDisjoint(tp1.tp2, tp2) || provablyDisjoint(tp1.tp1, tp2))
case (_, tp2: AndType) =>
provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1)
!(tp2 <:< tp1)
&& (provablyDisjoint(tp1, tp2.tp2) || provablyDisjoint(tp1, tp2.tp1))
case (tp1: TypeProxy, tp2: TypeProxy) =>
provablyDisjoint(tp1.underlying, tp2) || provablyDisjoint(tp1, tp2.underlying)
case (tp1: TypeProxy, _) =>
Expand Down
1 change: 0 additions & 1 deletion tests/patmat/andtype-opentype-interaction.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
27: Pattern Match Exhaustivity: _: Trait & OpenTrait & OpenTrait2, _: Clazz & OpenTrait & OpenTrait2, _: AbstractClass & OpenTrait & OpenTrait2, _: SealedClass & OpenTrait & OpenTrait2
31: Pattern Match Exhaustivity: _: Trait & OpenClass
35: Pattern Match Exhaustivity: _: Trait & OpenTrait & OpenClass
39: Pattern Match Exhaustivity: _: Trait & OpenClass & (OpenTrait & OpenClass2)
43: Pattern Match Exhaustivity: _: Trait & OpenAbstractClass
47: Pattern Match Exhaustivity: _: Trait & OpenClass & (OpenTrait & OpenClassSubclass)
2 changes: 1 addition & 1 deletion tests/patmat/andtype-opentype-interaction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Test {
}

def m2c(s: (T & OpenClass) & (OpenTrait & OpenClass2)) = s match {
case _: Unrelated => ;
case _: Unrelated => ; // OK since scrutinee is the empty type
}

def m3(s: T & OpenAbstractClass) = s match {
Expand Down
15 changes: 8 additions & 7 deletions tests/run/enum-Tree.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
trait P
enum Tree[T] {
case True extends Tree[Boolean]
case False extends Tree[Boolean]
case Zero extends Tree[Int]
case Succ(n: Tree[Int]) extends Tree[Int]
case Pred(n: Tree[Int]) extends Tree[Int]
case IsZero(n: Tree[Int]) extends Tree[Boolean]
case True extends Tree[Boolean], P
case False extends Tree[Boolean], P
case Zero extends Tree[Int], P
case Succ(n: Tree[Int]) extends Tree[Int], P
case Pred(n: Tree[Int]) extends Tree[Int], P
case IsZero(n: Tree[Int]) extends Tree[Boolean], P
case If(cond: Tree[Boolean], thenp: Tree[T], elsep: Tree[T])
extends Tree[T]
extends Tree[T], P
}

object Test {
Expand Down