aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt6
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
-rw-r--r--core/testdata/format/receiverParameterTypeBound.kt5
-rw-r--r--core/testdata/format/receiverParameterTypeBound.md20
4 files changed, 35 insertions, 0 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 2a69bb13..aaaffd6f 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -546,6 +546,12 @@ class DocumentationBuilder
if ((receiverClass as? ClassDescriptor)?.isCompanionObject ?: false) {
receiverClass = receiverClass.containingDeclaration!!
}
+ else if (receiverClass is TypeParameterDescriptor) {
+ val upperBoundClass = receiverClass.upperBounds.singleOrNull()?.constructor?.declarationDescriptor
+ if (upperBoundClass != null) {
+ receiverClass = upperBoundClass
+ }
+ }
link(receiverClass,
containingDeclaration,
RefKind.Extension)
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 509b5f39..427889c5 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -238,6 +238,10 @@ public class MarkdownFormatTest {
verifyMarkdownNodeByName("inapplicableExtensionFunctions", "Bar")
}
+ @Test fun receiverParameterTypeBound() {
+ verifyMarkdownNodeByName("receiverParameterTypeBound", "Foo")
+ }
+
private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) {
verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output ->
markdownService.appendNodes(tempLocation, output, model.members)
diff --git a/core/testdata/format/receiverParameterTypeBound.kt b/core/testdata/format/receiverParameterTypeBound.kt
new file mode 100644
index 00000000..2b5f6f17
--- /dev/null
+++ b/core/testdata/format/receiverParameterTypeBound.kt
@@ -0,0 +1,5 @@
+open class Foo {
+}
+
+fun <T : Foo> T.xyzzy() {
+}
diff --git a/core/testdata/format/receiverParameterTypeBound.md b/core/testdata/format/receiverParameterTypeBound.md
new file mode 100644
index 00000000..872158ac
--- /dev/null
+++ b/core/testdata/format/receiverParameterTypeBound.md
@@ -0,0 +1,20 @@
+[test](test/index) / [Foo](test/-foo/index)
+
+
+# Foo
+
+`open class Foo`
+
+
+
+### Constructors
+
+
+| [&lt;init&gt;](test/-foo/-init-) | `Foo()` |
+
+
+### Extension Functions
+
+
+| [xyzzy](test/xyzzy) | `fun &lt;T&nbsp;:&nbsp;[Foo](test/-foo/index)&gt; T.xyzzy(): Unit` |
+