Kotlin / dokka

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

Links to extensions with type parameters #3555

Open vmishenev opened 7 months ago

vmishenev commented 7 months ago
fun <T : Number> List<T>.foo() {}

interface MyListWithT<T> : List<T>

interface MyListWithTNumberBound<T : Number> : List<T>

interface MyListWithNumber : List<Number>

/**
 * 1 [List.foo]
 * 2 [MutableList.foo]
 * 3 [MyListWithT.foo]
 * 4 [MyListWithTNumberBound.foo]
 * 5 [MyListWithNumber.foo]
 */
fun usage() {}

In K1 - 1, 4 and 5 are resolved, but 2 and 3 are not. In K2 the easiest solution is implemented (without type inference) that resolves only 1.

Which references should be resolved?


This question has come from the review of https://youtrack.jetbrains.com/issue/KT-62695

can’t we approximate the type parameter’s type with its upper bound? This question is legal, of course Let’s look at some example:


fun <T : Number> List<T>.foo() {}

/**

interface MyListWithT : List

interface MyListWithTNumberBound : List

interface MyListWithNumber : List

/**

IgnatBeresnev commented 6 months ago

Blocking?

The specification around this should be discussed to make a decision.

whyoleg commented 2 months ago

Proposed expected behaviour could be found in KEEP: https://github.com/Kotlin/KEEP/blob/kdoc/extension-links/proposals/kdoc/links-to-extensions.md