Skip to content

Commit de6461a

Browse files
authored
Merge pull request #2256 from dotty-staging/fix-2254
fix #2254: dealias types in decomposition of spaces
2 parents 195fe4a + 15e8d83 commit de6461a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
324324

325325
debug.println(s"candidates for ${tp.show} : [${children.map(_.show).mkString(", ")}]")
326326

327-
tp match {
327+
tp.dealias match {
328328
case OrType(tp1, tp2) => List(Typ(tp1, true), Typ(tp2, true))
329329
case _ if tp =:= ctx.definitions.BooleanType =>
330330
List(
@@ -379,7 +379,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
379379
def canDecompose(tp: Type): Boolean = {
380380
val res = tp.classSymbol.is(allOf(Abstract, Sealed)) ||
381381
tp.classSymbol.is(allOf(Trait, Sealed)) ||
382-
tp.isInstanceOf[OrType] ||
382+
tp.dealias.isInstanceOf[OrType] ||
383383
tp =:= ctx.definitions.BooleanType ||
384384
tp.classSymbol.is(allOf(Enum, Sealed)) // Enum value doesn't have Sealed flag
385385

tests/patmat/i2254.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
type OrAlias = Int | Float
3+
4+
def m(s: OrAlias | String) = s match {
5+
case _: Int => ; case _: Float => ; case _: String => ; }
6+
}

0 commit comments

Comments
 (0)