Kotlin language spec claims identifiers are case-sensitive yet the following produces compiler error messages because of apparently case-insensitive generated getters/setters.
var a=10; var A=20
Clash.kt:1:1: error: platform declaration clash: The following declarations have the same JVM signature (getA()I):
fun <get-A>(): Int defined in root package
fun <get-a>(): Int defined in root package
var a=10
^
I understand what is happening but does this seem like the right behavior? Is there a way around this?
This has to do with how the compiler creates getters and setters to match the Java Beans standard. In this case, both of the getters and setters are named getA()
and setA(...)
because it tries to use the initial caps version of the field. If these fields were named aa
and AA
, however, you'd have getAa()
and getAA()
and wouldn't have a name collision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With