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

[K1] Incorrect Java synthetic properties #3128

Open
vmishenev opened this issue Aug 17, 2023 · 1 comment
Open

[K1] Incorrect Java synthetic properties #3128

vmishenev opened this issue Aug 17, 2023 · 1 comment
Labels
bug language: Java Issue/PR related to the Java language feature/analysis/docs language: Kotlin Issue/PR related to the Kotlin language feature/analysis/docs topic: K2 Issues / PRs that are related to the K2 migration. See #2888

Comments

@vmishenev
Copy link
Member

vmishenev commented Aug 17, 2023

In K2 interoperability with Java seems to be fixed since we get synthetic properties from Analysis API directly.
In K1 Dokka has plenty of uncovered corner cases, since Dokka handles such properties by itself.
Besides, even Dokka's unit tests are incorrect.

Discovered cases

  1. Dokka K1 removes the prefix is in the name of synthetic property.
    Example:
    The case is from our unit test. The name of this property should be isBool rather than bool.

The proof from IDE:

// FILE: A.java:
public class A {
    private boolean bool = true;
    public boolean isBool() { return bool; }
    public void setBool(boolean bool) { this.bool = bool; }
}

// FILE: foo.kt

fun foo(a: A) {
    a.isBool // property name is `isBool`, in Dokka K1 `bool`
}

class B : A  // B should have `bool` property
  1. Dokka K1 should display a synthetic property with a public backing field. Currently, it displays a field and accesors instead of a single property.
    Example: this test.
    The proof from IDE:
// FILE: A.java:
public class A {
    protected int a = 1; // or public
    public int getA() { return a; }
    public void setA(int a) { this.a = a; }
}

// FILE: foo.kt

fun foo(a: A) {
    a.a // property is available
}

class B : A  // B should just have  `a` property, but in Dokka K1  `a` field and `getA` and `setA`
@vmishenev vmishenev added the bug label Aug 17, 2023
@vmishenev vmishenev changed the title Incorrect Java synthetic properties from descriptors [K1] Incorrect Java synthetic properties Aug 29, 2023
@vmishenev vmishenev added the language: Kotlin Issue/PR related to the Kotlin language feature/analysis/docs label Aug 29, 2023
@IgnatBeresnev IgnatBeresnev added the topic: K2 Issues / PRs that are related to the K2 migration. See #2888 label Oct 13, 2023
@IgnatBeresnev
Copy link
Member

Update after an internal discussion:

  • No plans to fix this bug / inconsistency for K1 analysis - we have little time on our hands, and we want to focus on K2 (in K2 analysis this particular bug does not exist)
  • The tests that have been muted due to this bug need to be adapted (to represent the expected behaviour) and unmuted. After this, the issue can be closed.

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

No branches or pull requests

2 participants