dokka
dokka copied to clipboard
[K2] Incorrect modifier for property from getter/setter
The case is pretty synthetic, but I had such code in my project, so
Parent.java
public class Parent {
public int publicPropertyWithProtectedGetterProtectedSetter = 0;
protected int getPublicPropertyWithProtectedGetterProtectedSetter() {
return publicPropertyWithProtectedGetterProtectedSetter;
}
protected void setPublicPropertyWithProtectedGetterProtectedSetter(int publicPropertyWithProtectedGetterProtectedSetter) {
this.publicPropertyWithProtectedGetterProtectedSetter = publicPropertyWithProtectedGetterProtectedSetter;
}
}
Child.kt
open class Child: Parent()
In K1 Child list member is just the same as in the code:
In K2 getter/setter is omitted. But for some reason protected
wins over public
Installation
- Dokka version: 1.9.20 Parent: https://github.com/Kotlin/dokka/issues/3328
The behaviour inside IntelliJ IDEA differs based on context, and differs based on usage (i.e it might not show getters/setters in autocomplete, but it doesn't mean it'll show an error if you invoke it manually). So the IDE is flexible, it has fewer constraints.
Dokka, on the other hand, only has a single static HTML page for such classes, so we need to figure out what to show our users - do we show them getters and setters? Should DokkaConfiguration#visibility
play a role here?
We should also ask if K2 changes Java-Kotlin interop in any known and significant way, and if they have any sort of "specification" tests that would make sure the behaviour hasn't changed in a major way.
Spike: #3576
Is blocking?
- Testing: no
- Beta: yes (not necessarily the fix, but need to figure out how it should work)
It is related to https://github.com/Kotlin/dokka/issues/3338#issuecomment-2112381563
Also, we decided to not distinguish the protected
keyword between Kotlin and Java since it seems the use case when an Java declaration is externally used within the same package is unpopular.
In Kotlin - visible in subclasses In Java - visible in subclasses and the same package