From 9c1d23b8bfa74b74a036d9500d8f8d57c978e553 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 7 Nov 2017 16:10:05 +0300 Subject: Fix problem with Java descriptors --- .../kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt index ca15b89f..266361f2 100644 --- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt +++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt @@ -9,9 +9,14 @@ import org.jetbrains.kotlin.psi.KtElement class KotlinAsJavaDescriptorSignatureProvider : DescriptorSignatureProvider { override fun signature(forDesc: DeclarationDescriptor): String { + val sourcePsi = forDesc.sourcePsi() + val javaLikePsi = if (sourcePsi is KtElement) { + sourcePsi.toLightElements().firstOrNull() + } else { + sourcePsi + } - val sourcePsi = forDesc.sourcePsi() as? KtElement - return getSignature(sourcePsi?.toLightElements().orEmpty().firstOrNull()) ?: + return getSignature(javaLikePsi) ?: throw UnsupportedOperationException("Don't know how to calculate signature for $forDesc") } } \ No newline at end of file -- cgit