aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt21
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt4
-rw-r--r--core/testdata/format/linkWithStarProjection.html24
-rw-r--r--core/testdata/format/linkWithStarProjection.kt3
4 files changed, 47 insertions, 5 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 8cead63e..fc181252 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -764,12 +764,23 @@ fun CallableMemberDescriptor.parameterSignature(): String {
}
fun KotlinType.signature(): String {
- val declarationDescriptor = constructor.declarationDescriptor ?: return "<null>"
- val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString()
- if (arguments.isEmpty()) {
- return typeName
+ val visited = hashSetOf<KotlinType>()
+
+ fun KotlinType.signatureRecursive(): String {
+ if (this in visited) {
+ return ""
+ }
+ visited.add(this)
+
+ val declarationDescriptor = constructor.declarationDescriptor ?: return "<null>"
+ val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString()
+ if (arguments.isEmpty()) {
+ return typeName
+ }
+ return typeName + arguments.joinToString(prefix = "((", postfix = "))") { it.type.signatureRecursive() }
}
- return typeName + arguments.joinToString(prefix = "((", postfix = "))") { it.type.signature() }
+
+ return signatureRecursive()
}
fun DeclarationDescriptor.signatureWithSourceLocation(): String {
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
index 0b4f9958..9936b8e2 100644
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/HtmlFormatTest.kt
@@ -168,6 +168,10 @@ class HtmlFormatTest {
verifyHtmlNode("returnWithLink")
}
+ @Test fun linkWithStarProjection() {
+ verifyHtmlNode("linkWithStarProjection", withKotlinRuntime = true)
+ }
+
private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
verifyOutput("testdata/format/$fileName.kt", ".html", withKotlinRuntime = withKotlinRuntime) { model, output ->
htmlService.appendNodes(tempLocation, output, model.members.single().members)
diff --git a/core/testdata/format/linkWithStarProjection.html b/core/testdata/format/linkWithStarProjection.html
new file mode 100644
index 00000000..0e829e80
--- /dev/null
+++ b/core/testdata/format/linkWithStarProjection.html
@@ -0,0 +1,24 @@
+<HTML>
+<HEAD>
+<title>KClassLoader - test</title>
+</HEAD>
+<BODY>
+<a href="test/index">test</a>&nbsp;/&nbsp;<a href="test/-k-class-loader/index">KClassLoader</a><br/>
+<br/>
+<h1>KClassLoader</h1>
+<code><span class="keyword">object </span><span class="identifier">KClassLoader</span></code><br/>
+<br/>
+<br/>
+<h3>Functions</h3>
+<table>
+<tbody>
+<tr>
+<td>
+<a href="test/-k-class-loader/foo">foo</a></td>
+<td>
+<code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="identifier" id="KClassLoader$foo(kotlin.Enum(()))/c">c</span><span class="symbol">:</span>&nbsp;<span class="identifier">Enum</span><span class="symbol">&lt;</span><span class="identifier">*</span><span class="symbol">&gt;</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
+</tr>
+</tbody>
+</table>
+</BODY>
+</HTML>
diff --git a/core/testdata/format/linkWithStarProjection.kt b/core/testdata/format/linkWithStarProjection.kt
new file mode 100644
index 00000000..6da6c595
--- /dev/null
+++ b/core/testdata/format/linkWithStarProjection.kt
@@ -0,0 +1,3 @@
+object KClassLoader {
+ fun foo(c: Enum<*>) { }
+}