Skip to content

[K1] Incorrect Java synthetic properties #3128

@vmishenev

Description

@vmishenev

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglanguage: JavaIssue/PR related to the Java language feature/analysis/docslanguage: KotlinIssue/PR related to the Kotlin language feature/analysis/docstopic: K2Issues / PRs that are related to the K2 migration. See #2888

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions