From a94b5c3cfcbbeba71ae00794bf131f532a382013 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 5 May 2022 14:37:50 +0100 Subject: [PATCH] Force Java enum children to be queried --- compiler/src/dotty/tools/dotc/core/SymDenotations.scala | 2 +- .../src/dotty/tools/dotc/transform/patmat/Space.scala | 3 ++- tests/pos/i14807.scala | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i14807.scala diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index e1a54325af03..ce42f352a042 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1613,7 +1613,7 @@ object SymDenotations { c.ensureCompleted() end completeChildrenIn - if is(Sealed) then + if is(Sealed) || isAllOf(JavaEnumTrait) then if !is(ChildrenQueried) then // Make sure all visible children are completed, so that // they show up in Child annotations. A possible child is visible if it diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index de07fec74acb..fb4fbd653ee5 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -1,4 +1,5 @@ -package dotty.tools.dotc +package dotty.tools +package dotc package transform package patmat diff --git a/tests/pos/i14807.scala b/tests/pos/i14807.scala new file mode 100644 index 000000000000..7d3dbbcbed66 --- /dev/null +++ b/tests/pos/i14807.scala @@ -0,0 +1,9 @@ +// scalac: -Werror +enum Foo: + case One(value: String) + case Two(value: Long, month: java.time.Month) + +object Issue: + def doSomething(foo: Foo): String = foo match + case Foo.One(x) => s"1 $x" + case Foo.Two(x, y) => s"2 $x $y"