From ffc130f5fb8dd99665d1a32ce6822a694ab4488b Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Fri, 9 Jun 2017 12:38:44 +0300 Subject: [PATCH] [NI] Always approximate captured types for property descriptors --- .../kotlin/resolve/calls/components/KotlinCallCompleter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt index e0f1a1c1f52..fcc29d5d65e 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt @@ -37,7 +37,9 @@ import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateStatus import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.UnwrappedType import org.jetbrains.kotlin.types.checker.KotlinTypeChecker +import org.jetbrains.kotlin.types.checker.NewCapturedType import org.jetbrains.kotlin.types.typeUtil.builtIns +import org.jetbrains.kotlin.types.typeUtil.contains import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.addIfNotNull @@ -139,9 +141,10 @@ class KotlinCallCompleter( } private fun SimpleKotlinResolutionCandidate.toCompletedCall(substitutor: NewTypeSubstitutor): CompletedKotlinCall.Simple { + val containsCapturedTypes = descriptorWithFreshTypes.returnType?.contains { it is NewCapturedType } ?: false val resultingDescriptor = when { descriptorWithFreshTypes is FunctionDescriptor || - descriptorWithFreshTypes is PropertyDescriptor && descriptorWithFreshTypes.typeParameters.isNotEmpty() -> + (descriptorWithFreshTypes is PropertyDescriptor && (descriptorWithFreshTypes.typeParameters.isNotEmpty() || containsCapturedTypes)) -> // this code is very suspicious. Now it is very useful for BE, because they cannot do nothing with captured types, // but it seems like temporary solution. descriptorWithFreshTypes.substituteAndApproximateCapturedTypes(substitutor)