Closed
Description
Minimized code
There is no syntax for an individual java enum case to implement a new interface, e.g. the following is an error
public enum Foo {
Red implements java.util.Function<Integer, Boolean> {
public Boolean apply(Integer i){
return i > 3 ;
}
},
Green,
Blue
}
Note: you can make a Java enum case as an anonymous subclass, it just can't add new parents to what the enum already implements. e.g.
public enum Foo implements java.util.Function<Integer, Boolean> {
case One {
public Boolean apply(Integer i){
return i == 1 ;
}
}
case Two {
public Boolean apply(Integer i){
return i == 2 ;
}
}
}
Expectation
so therefore the following should be an error in dotty:
object FancyColours {
sealed trait Pretty { self: Colour => }
sealed trait Dull { self: Colour => }
enum Colour extends java.lang.Enum[Colour] {
case Pink extends Colour with Pretty
case Red extends Colour with Dull
}
}
This prevents any optimisation of typing java enums as an EnumTag Constant