From 75fa02646b66e7ff09d88a7a779f5fcf4742fa4d Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 11 Jul 2018 20:08:34 +0300 Subject: [PATCH] EA-109046: Add diagnostic to catch NPE --- .../src/org/jetbrains/kotlin/idea/util/FuzzyType.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 1f50cf999ed..690dfc974ed 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.StrictEqualityTypeChecker import org.jetbrains.kotlin.types.typeUtil.* +import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.util.* fun CallableDescriptor.fuzzyReturnType() = returnType?.toFuzzyType(typeParameters) @@ -88,9 +89,13 @@ class FuzzyType( } } + // Diagnostic for EA-109046 + @Suppress("USELESS_ELVIS") private fun TypeParameterDescriptor.toOriginal(): TypeParameterDescriptor { val callableDescriptor = containingDeclaration as? CallableMemberDescriptor ?: return this - return callableDescriptor.original.typeParameters[index] + val original = callableDescriptor.original ?: error("original = null for $callableDescriptor") + val typeParameters = original.typeParameters ?: error("typeParameters = null for $original") + return typeParameters[index] } override fun equals(other: Any?) = other is FuzzyType && other.type == type && other.freeParameters == freeParameters