https://kotlinlang.org logo
Title
l

LastExceed

02/09/2022, 12:53 PM
why doesn't L13 work ?
s

Sam

02/09/2022, 12:56 PM
The
values()
method on an enum isn't actually a member of its companion object. (If it was, you wouldn't be able to define a new companion object, because there would already be one).
The docs describe it as a "synthetic method"
I think you actually can define your own
values()
method in the companion object, but it won't override the built-in one.
MyEnum.values()
will always resolve to the built-in method and will ignore the one in the companion object.
I'm guessing that KT-11968 will provide a route to resolve this oddity in the language design, which presumably stems from Java interop
l

LastExceed

02/09/2022, 1:34 PM
thanks
s

Sam

02/09/2022, 1:35 PM
No problem, sorry it's not a more satisfying explanation
This is definitely one of Kotlin's rough edges