Skip to content

Commit 6b78047

Browse files
committed
Improve recursive decompose prefix fix
1 parent ec2b8bc commit 6b78047

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ object SpaceEngine {
619619
case OrType(tp1, tp2) => List(tp1, tp2)
620620
case tp if tp.isRef(defn.BooleanClass) => List(ConstantType(Constant(true)), ConstantType(Constant(false)))
621621
case tp if tp.isRef(defn.UnitClass) => ConstantType(Constant(())) :: Nil
622-
case tp @ NamedType(Parts(parts), _) => parts.map(tp.derivedSelect)
622+
case tp @ NamedType(Parts(parts), _) => if parts.exists(_ eq tp) then ListOfNoType else parts.map(tp.derivedSelect)
623623
case _: SingletonType => ListOfNoType
624624
case tp if tp.classSymbol.isAllOf(JavaEnum) => tp.classSymbol.children.map(_.termRef)
625625
// the class of a java enum value is the enum class, so this must follow SingletonType to not loop infinitely

tests/pos/i19031.ci-reg1.scala renamed to tests/warn/i19031.ci-reg1.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Werror
2-
31
sealed trait Mark[T]
42

53
trait Foo[T]

tests/pos/i19031.ci-reg2.scala renamed to tests/warn/i19031.ci-reg2.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Werror
2-
31
trait Outer:
42
sealed trait Foo
53
case class Bar1() extends Foo

tests/pos/i19031.scala renamed to tests/warn/i19031.scala

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Werror
2-
31
sealed trait A:
42
class B extends A
53

tests/warn/i19031b.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sealed trait A:
2+
class B extends A
3+
4+
class C extends A
5+
6+
class Test:
7+
def t1(a: A): Boolean =
8+
a match
9+
case b: A#B => true
10+
case c: C => true

0 commit comments

Comments
 (0)