Skip to content
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

Inconsistency in visibility of protected properties #2536

Closed
atyrin opened this issue Jun 16, 2022 · 2 comments · Fixed by #2532
Closed

Inconsistency in visibility of protected properties #2536

atyrin opened this issue Jun 16, 2022 · 2 comments · Fixed by #2532
Labels

Comments

@atyrin
Copy link
Contributor

atyrin commented Jun 16, 2022

Let's have a code like:

public class JavaClsWithProperties {
    protected int protectedProperty = 0;
    private int protectedGetterAndProtectedSetter = 0;

    protected int getProtectedGetterAndProtectedSetter() {
        return protectedGetterAndProtectedSetter;
    }

    protected void setProtectedGetterAndProtectedSetter(int protectedGetterAndProtectedSetter) {
        this.protectedGetterAndProtectedSetter = protectedGetterAndProtectedSetter;
    }
}

and inheritor

open class InheritJavaClsProperties: JavaClsWithProperties(){
    protected val protectedX: Int = 0
}

What we see in generated documentation with default documentedVisibilities (Public API only):
For Java property with protected getter/setter is shown
image
For inheritor in Kotlin both properties are shown
image

Expected behaviour
My expectation is that all protected properties are hidden. But probably for an open class, they might be shown with the visibility modifier.

Installation

  • Dokka version: 1.7.0
  • Kotlin: 1.7.0
@atyrin atyrin added the bug label Jun 16, 2022
@IgnatBeresnev IgnatBeresnev linked a pull request Jun 16, 2022 that will close this issue
@IgnatBeresnev
Copy link
Member

These are actually two separate bugs:

  1. Incorrect mapping of Java's Protected visibility, it resolved to Kotlin's Public. Fixed it, now Java.Protected -> Kotlin.Protected
  2. non-public-api fields with accessors that are public api were hardcoded to be Kotlin.Public, that was a mistake. Made it so that property visibility is inherited from getter's visibility. So for a field with a protected getter it will generate a protected kotlin property

@atyrin
Copy link
Contributor Author

atyrin commented Jun 16, 2022

One more case in the same area. Protected property and public getter and setter.

public class JavaClsWithProperties {
    protected int publicGetterAndPublicSetter = 0;

    public int getPublicGetterAndPublicSetter() {
        return publicGetterAndPublicSetter;
    }

    public void setPublicGetterAndPublicSetter(int publicGetterAndPublicSetter) {
        this.publicGetterAndPublicSetter = publicGetterAndPublicSetter;
    }
}

In that case for the inheritor in Kotlin Dokka doesn't show the property but it is available. If protected switch to e.g. private then property is shown.

Dokka: 1.7.0-dev-170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants