Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.45k stars 409 forks source link

[K2] Methods implemented by delegation miss the `override` keyword and KDoc #3384

Closed atyrin closed 7 months ago

atyrin commented 11 months ago
interface CookieJar {
    /**
     * Saves cookies
     */
    fun saveFromResponse(url: String)
}

class CookieJarImpl() : CookieJar {
    override fun saveFromResponse(url: String) {}
}

class JavaNetCookieJar private constructor(
    delegate: CookieJarImpl,
) : CookieJar by delegate

With K1 the JavaNetCookieJar got override keyword and kdoc from the interface

image

In K2 both are missed:

image

Installation

Parent: https://github.com/Kotlin/dokka/issues/3328

IgnatBeresnev commented 11 months ago

We consider K1's behaviour to be correct in this case, so there should be the override keyword.

vmishenev commented 10 months ago

It can be implemented on Dokka's side. See K1 implementation for descriptors: https://github.com/JetBrains/kotlin/blob/5fba2962b9b5f6cb105fcd81dbd5f259cdd0db1d/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java#L138

    public static boolean isOverride(@NotNull CallableMemberDescriptor descriptor) {
        return !descriptor.getOverriddenDescriptors().isEmpty();
    }
vmishenev commented 10 months ago

Currently, in K2 members implemented by delegation have their own pages and have no KDoc. In K1 they refer to overriden declarations.

It is blocked by https://youtrack.jetbrains.com/issue/KT-64833/Analysis-API-Members-implemented-by-delegation-have-no-overridden-symbols to implement it like in K1.

Also related: #3196

IgnatBeresnev commented 7 months ago

This has been unblocked and fixed upstream, just need to check it and write a test.

Note: in K2 if a class inherits a function from an interface, clicking on this function in the child should lead to the interface.

The PR #3440 can be resurrected, but not necessarily