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

[K2] Incorrect modifier for property from getter/setter #3339

Open
atyrin opened this issue Nov 13, 2023 · 3 comments
Open

[K2] Incorrect modifier for property from getter/setter #3339

atyrin opened this issue Nov 13, 2023 · 3 comments
Labels
bug topic: K2 Issues / PRs that are related to the K2 migration. See #2888

Comments

@atyrin
Copy link
Contributor

atyrin commented Nov 13, 2023

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:
image


In K2 getter/setter is omitted. But for some reason protected wins over public
image

Installation

@atyrin atyrin added the bug label Nov 13, 2023
@IgnatBeresnev IgnatBeresnev added the topic: K2 Issues / PRs that are related to the K2 migration. See #2888 label Nov 13, 2023
@IgnatBeresnev
Copy link
Member

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.

@IgnatBeresnev
Copy link
Member

IgnatBeresnev commented Apr 26, 2024

Spike: #3576

Is blocking?

  • Testing: no
  • Beta: yes (not necessarily the fix, but need to figure out how it should work)

@vmishenev
Copy link
Member

vmishenev commented May 15, 2024

It is related to #3338 (comment)
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug topic: K2 Issues / PRs that are related to the K2 migration. See #2888
Projects
None yet
Development

No branches or pull requests

3 participants