Skip to content

Commit

Permalink
Fix scala#11973: Bail out on EnumValues
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed May 20, 2021
1 parent 4bf2f04 commit d645f5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
case (tp1: TermRef, tp2: TermRef) if isEnumValueOrModule(tp1) && isEnumValueOrModule(tp2) =>
tp1.termSymbol != tp2.termSymbol
case (tp1: TermRef, _) if isEnumValueOrModule(tp1) =>
false
case (_, tp2: TermRef) if isEnumValueOrModule(tp2) =>
false
case (tp1: Type, tp2: Type) if defn.isTupleType(tp1) =>
provablyDisjoint(tp1.toNestedPairs, tp2)
case (tp1: Type, tp2: Type) if defn.isTupleType(tp2) =>
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/11973.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enum E:
case C

trait T

def f(x: E | T): Unit = x match {
case e: E => ()
case t: T => ()
}

0 comments on commit d645f5a

Please sign in to comment.