Skip to content

Commit 5efc3b5

Browse files
committed
Fix #12602: Only generate sum mirrors for sealed trait or sealed abstract class
1 parent 9a0182a commit 5efc3b5

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ object SymUtils:
100100
def whyNotGenericSum(declScope: Symbol)(using Context): String =
101101
if (!self.is(Sealed))
102102
s"it is not a sealed ${self.kindString}"
103+
else if (!self.isOneOf(AbstractOrTrait))
104+
s"it is not an abstract class"
103105
else {
104106
val children = self.children
105107
val companionMirror = self.useCompanionAsMirror

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

+3
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
846846

847847
if (!exhaustivityCheckable(sel)) return
848848

849+
debug.println("checking " + _match.show)
850+
debug.println("selTyp = " + selTyp.show)
851+
849852
val patternSpace = Or(cases.foldLeft(List.empty[Space]) { (acc, x) =>
850853
val space = if (x.guard.isEmpty) project(x.pat) else Empty
851854
debug.println(s"${x.pat.show} ====> ${show(space)}")

tests/patmat/i12602.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sealed class Foo[T]
2+
object Foo extends Foo[Nothing]

0 commit comments

Comments
 (0)