Closed
Description
When overriding toString
in an enum, simple cases end up using their name instead of this new implementation.
minimized code
enum E:
case A
override def toString: String = "overriden"
println(E.A)
expectation
overriden
result
A
Note that adding an argument to that enum
case will return the right result again:
enum E:
case A(arg: Unit)
override def toString: String = "overriden"
println(E.A)
This prints overriden
as expected.
This has something to do with the desugaring of enums, and the generation of a default toString
method.