Suppose we have a property with default accessors
class Person() {
var name = "Bob"
}
Am I right I cannot call the default accessor directly?
I mean, instead of
val person = Person()
var personName = person.name
I cannot write
val person = Person()
var personName = person.getName()
But when I try to define fun getName(): String
inside Person class I’m getting an error
Platform declaration clash: The following declarations have the same JVM signature
I could not find any explanation neither in documentation nor in the language specification. For me it looks inconsistent: I should either be able to call accessors directly or should not get such an error (which is not possible due to JVM limitations, I suppose).
It would be nice to have some mention of such behaviour in the Kotlin documentation, I guess.