Skip to content

Commit 20026ec

Browse files
committed
Space: Fix decomposable, dont recurse on Java enums
1 parent 475f015 commit 20026ec

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,9 @@ object SpaceEngine {
613613
case OrType(tp1, tp2) => List(tp1, tp2)
614614
case tp if tp.isRef(defn.BooleanClass) => List(ConstantType(Constant(true)), ConstantType(Constant(false)))
615615
case tp if tp.isRef(defn.UnitClass) => ConstantType(Constant(())) :: Nil
616-
case tp if tp.classSymbol.isAllOf(JavaEnumTrait) => tp.classSymbol.children.map(_.termRef)
617616
case tp @ NamedType(Parts(parts), _) => parts.map(tp.derivedSelect)
618617
case _: SingletonType => ListOfNoType
618+
case tp if tp.classSymbol.isAllOf(JavaEnumTrait) => tp.classSymbol.children.map(_.termRef)
619619

620620
case tp @ AppliedType(Parts(parts), targs) if tp.classSymbol.children.isEmpty =>
621621
// It might not obvious that it's OK to apply the type arguments of a parent type to child types.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public enum ParameterModifier {
2+
Repeated,
3+
Plain,
4+
ByName;
5+
6+
private ParameterModifier() {
7+
}
8+
}

tests/patmat/java-enum1/Test.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Test:
2+
private def showParameterModifier(base: String, pm: ParameterModifier): String = pm match {
3+
case ParameterModifier.Plain => base
4+
case ParameterModifier.Repeated => base + "*"
5+
case ParameterModifier.ByName => "=> " + base
6+
}

0 commit comments

Comments
 (0)