From adb36d53fe4eef61e02aa9d6841689a476c445d5 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Wed, 22 Nov 2017 20:04:19 +0300 Subject: [PATCH] Fix bug when chain result type inferred incorrectly --- .../kotlin/psi/impl/KotlinCollectionsTypeExtractor.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/idea/idea-jvm/src/com/intellij/debugger/streams/kotlin/psi/impl/KotlinCollectionsTypeExtractor.kt b/idea/idea-jvm/src/com/intellij/debugger/streams/kotlin/psi/impl/KotlinCollectionsTypeExtractor.kt index fd526b8cb9f..97f34411c30 100644 --- a/idea/idea-jvm/src/com/intellij/debugger/streams/kotlin/psi/impl/KotlinCollectionsTypeExtractor.kt +++ b/idea/idea-jvm/src/com/intellij/debugger/streams/kotlin/psi/impl/KotlinCollectionsTypeExtractor.kt @@ -10,7 +10,6 @@ import com.intellij.debugger.streams.kotlin.trace.dsl.KotlinTypes import com.intellij.debugger.streams.kotlin.trace.dsl.KotlinTypes.ANY import com.intellij.debugger.streams.kotlin.trace.dsl.KotlinTypes.NULLABLE_ANY import com.intellij.debugger.streams.trace.impl.handler.type.ArrayType -import com.intellij.debugger.streams.trace.impl.handler.type.ClassTypeImpl import com.intellij.debugger.streams.trace.impl.handler.type.GenericType import com.intellij.openapi.diagnostic.Logger import org.jetbrains.kotlin.psi.KtCallExpression @@ -63,10 +62,15 @@ class KotlinCollectionsTypeExtractor : CallTypeExtractor { private fun defaultType(type: KotlinType): GenericType { LOG.warn("Could not find type of items for type ${KotlinPsiUtil.getTypeName(type)}") - return NULLABLE_ANY + return getAny(type) } - private fun getResultType(type: KotlinType): GenericType = ClassTypeImpl(KotlinPsiUtil.getTypeName(type)) + private fun getResultType(type: KotlinType): GenericType { + val typeName = KotlinPsiUtil.getTypeWithoutTypeParameters(type) + return tryToGetPrimitiveByName(typeName) ?: tryToGetPrimitiveArrayByName(typeName) ?: getAny(type) + } + + private fun getAny(type: KotlinType): GenericType = if (type.isMarkedNullable) NULLABLE_ANY else ANY private fun tryToGetPrimitiveByName(name: String): GenericType? = primitives.firstOrNull { x -> x.variableTypeName == name }