dokka icon indicating copy to clipboard operation
dokka copied to clipboard

[K2] Inconsistent member representation for Java/Kotlin files

Open atyrin opened this issue 1 year ago • 4 comments

Parent.java:

public class Parent {
    protected int protectedPropertyWithPublicGetterPublicSetter = 0;

    public int getProtectedPropertyWithPublicGetterPublicSetter() {
        return protectedPropertyWithPublicGetterPublicSetter;
    }

    public void setProtectedPropertyWithPublicGetterPublicSetter(int protectedPropertyWithPublicGetterPublicSetter) {
        this.protectedPropertyWithPublicGetterPublicSetter = protectedPropertyWithPublicGetterPublicSetter;
    }
}

Child.kt

open class Child: Parent()

In K1, both pages look the same:

image

In K2, the page for Java parent looks the same as in K1. But for Kotlin, inheritor getter/setter methods are omitted. image

Representation in K2 for Kotlin files looks correct (as no getters/setters are available in the code). But it seems for the Java class, it should be the same.

Installation

  • Dokka version: 1.9.20

Parent: #3328

atyrin avatar Nov 13 '23 16:11 atyrin

Related: #3128

atyrin avatar Nov 14 '23 08:11 atyrin

For the given code, the child's page and the parent's page should look the same, as for the K2 child's page, so like this

image

IgnatBeresnev avatar Dec 08 '23 13:12 IgnatBeresnev

Blocked by #3576

IgnatBeresnev avatar Apr 22 '24 10:04 IgnatBeresnev

The summary based on the spike https://github.com/Kotlin/dokka/issues/3576: Presumably we decided to show a backing field, a getter, and a setter always. We are going to ask to validate our decision other teams, e.g. Kotlin Evolution (as they can have plans on https://youtrack.jetbrains.com/issue/KT-6653).


We are not sure about the case with a private field:

public class A {
   private int prop = 1;
   public int getProp() {
       return prop;
   }
   public void setProp(int a) {
       this.prop = a;
   }
}

Should Dokka display accessors here?! Despite the counter-example below, It seems a field and its accessors should be an united entity.

class B : A() {
    override fun getProp(): Int {
        ....
    }
    override fun setProp(a: Int) {
        ...
    }
}

vmishenev avatar May 15 '24 12:05 vmishenev