-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private Java field with public accessors has private keyword in Kotlin signature #2439
Comments
Hi! I believe this is how kotlin-java interop works:
So I don't think your expected behaviour is correct, it would simply be wrong even compared to the Intellij IDEA. In Kotlin, there's no concept of getters and setters However, it is indeed wrong that the word |
For anyone looking to fix this, here's the expected behaviour. For the java class public class TestClass {
private int a;
public int getA() {
return a;
}
public void setA(int a) {
}
} it should generate the following signature: It seems to be a relatively easy fix for in terms of writing code, here's where the problem is: KotlinSignatureProvider#propertySignature. It should throw away The fix should be roughly something like this (should be cleaned up of course): p.visibility[sourceSet].takeIf {
val isPrivateJavaPropertyWithPublicAccessors =
(it == JavaVisibility.Private)
&& (p.getter?.visibility?.get(sourceSet) == JavaVisibility.Public)
&& (p.setter?.visibility?.get(sourceSet) == JavaVisibility.Public)
it !in ignoredVisibilities && !isPrivateJavaPropertyWithPublicAccessors
}?.name?.let { keyword("$it ") } However, fixing this will involve some thinking and testing for corner cases:
And more tests with corner cases will need to be added. |
Will be fixed in #2532, thanks for the report! |
Hi! I still experience this issue in 1.8.20. |
@EvgeniyMish could you please share the use case? A number of unit tests were written in #2439, so it's unlikely to be a regression - most likely it's a different bug or yet another corner case |
Can some one please provide an example on how to use documentedVisibilities to generate documentation for public accessors (get and set) with private field. I already tried No errors where produced but documentation for get set functions were also not produced I am using groovy |
Describe the bug
I have a module mixed with java/kotlin classes in Android project. Generating docs with includeNonPublic set to false still adds Java non-public properties (that have public getter/setter specifically) to the output while their getter and setter not outputted.
Expected behaviour
Non-public properties not visible in the html output while their public getter and setter are visible.
Screenshots
Current generated doc page:
To Reproduce
Dokka configuration
Configuration of dokka used to reproduce the bug
Module build.gradle:
kdoc.gradle:
Project build.gradle:
Installation
Additional context
I see this issue since Dokka version 1.4.32
The text was updated successfully, but these errors were encountered: