From 03d567b763839323ab13d2f385395b221da06023 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 28 Apr 2016 17:55:46 +0200 Subject: SOE protection when calculating type signature. Resolves #69 --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'core/src/main/kotlin/Kotlin') 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 "" - val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString() - if (arguments.isEmpty()) { - return typeName + val visited = hashSetOf() + + fun KotlinType.signatureRecursive(): String { + if (this in visited) { + return "" + } + visited.add(this) + + val declarationDescriptor = constructor.declarationDescriptor ?: return "" + 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 { -- cgit