Skip to content

Commit ef59012

Browse files
authored
Merge pull request #15109 from dwijnand/fix-unreachable-inhabited-java-enum
Force Java enum children to be queried
2 parents cf3b59a + a94b5c3 commit ef59012

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ object SymDenotations {
16131613
c.ensureCompleted()
16141614
end completeChildrenIn
16151615

1616-
if is(Sealed) then
1616+
if is(Sealed) || isAllOf(JavaEnumTrait) then
16171617
if !is(ChildrenQueried) then
16181618
// Make sure all visible children are completed, so that
16191619
// they show up in Child annotations. A possible child is visible if it

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package dotty.tools.dotc
1+
package dotty.tools
2+
package dotc
23
package transform
34
package patmat
45

tests/pos/i14807.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// scalac: -Werror
2+
enum Foo:
3+
case One(value: String)
4+
case Two(value: Long, month: java.time.Month)
5+
6+
object Issue:
7+
def doSomething(foo: Foo): String = foo match
8+
case Foo.One(x) => s"1 $x"
9+
case Foo.Two(x, y) => s"2 $x $y"

0 commit comments

Comments
 (0)