aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-04-28 17:55:46 +0200
committerDmitry Jemerov <yole@jetbrains.com>2016-04-28 17:55:46 +0200
commit03d567b763839323ab13d2f385395b221da06023 (patch)
tree09a60efbb9ff626f0773a823a9acf0c3a94bddb5 /core/src/main/kotlin
parent25278e2697af68788f8efdbe32b29f0ed42f33b4 (diff)
downloaddokka-03d567b763839323ab13d2f385395b221da06023.tar.gz
dokka-03d567b763839323ab13d2f385395b221da06023.tar.bz2
dokka-03d567b763839323ab13d2f385395b221da06023.zip
SOE protection when calculating type signature. Resolves #69
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt21
1 files changed, 16 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 {