dokka icon indicating copy to clipboard operation
dokka copied to clipboard

[K2] Ambiguous KDoc link with the same name

Open vmishenev opened this issue 1 year ago • 5 comments
trafficstars

            /**
            *  [AllKDocTagsClass]
            */
            class AllKDocTagsClass {
                class AllKDocTagsClass
            }

In K1 [AllKDocTagsClass] leads to AllKDocTagsClass.AllKDocTagsClass class. In K2 it leads to the first AllKDocTagsClass.

Related: #3179

vmishenev avatar Jan 16 '24 22:01 vmishenev

fun x(){}
/**
* ref to [x]
*/
val x = 0

In K1 the [x] leads to fun x. In K2 it leads only to the property.

But in the following example

fun x(){}
val x = 0
/**
* ref to [x]
*/
val x2 = 0

K2 x has 2 candidates. see #3447

vmishenev avatar Jan 18 '24 19:01 vmishenev

This is a question for the KDoc specification. Maybe we don't need to do anything, maybe some changes will be required on our side or on the Analysis API side. Depends on how we decide it should work

IgnatBeresnev avatar Jan 19 '24 13:01 IgnatBeresnev

K2 behavior for factory functions:

/**
 * [SomeCl] leads to the class
 */
class SomeCl(i: Int)

/**
 * [SomeCl] leads to the factory function 
 * In K1, it leads to the class
 * [a] and [b] lead to the params in K1 and K2
 */
fun SomeCl(i: Int, b: Int): SomeCl = TODO()

/**
 * [SomeCl] leads to the class (In Dokka)
 */
fun other() {}

Non-obvious side effect: (fix!?)

/**
 * [CoroutineScope.cancel] is resolved
 */
interface CoroutineScope
/**
 * [CoroutineScope.cancel] is unresolved since here [CoroutineScope] is a function
 */
fun CoroutineScope(i:Int): CoroutineScope = TODO()
/**
 * [CoroutineScope.cancel] is resolved
 */
fun CoroutineScope.cancel(): CoroutineScope = TODO()


image

vmishenev avatar May 27 '24 16:05 vmishenev

one more case:

    public open class C2 {
        class A2
    }

    public class A2

    /**
     * [A2] leads to C2.A2
     */
    public class SomeClass : C2()

vmishenev avatar May 28 '24 11:05 vmishenev

This issues was addressed in https://github.com/Kotlin/KEEP/issues/389

vmishenev avatar Aug 26 '24 13:08 vmishenev