From 4ad885afb0b94fbfad3a9313ad77c035793ff41a Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 26 Oct 2017 18:38:39 +0300 Subject: [PATCH] [NI] Correctly propagate base constraint system of `invoke` call Consider the following example: class A { operator fun invoke(): Foo = throw Exception() } fun foo(f: Foo) {} fun test(a: A) { foo(a()) // after resolve of `invoke`, it has non-fixed type variable } --- .../calls/tower/KotlinToResolvedCallTransformer.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index 5f6d3783933..2ce99e15d0c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -87,7 +87,13 @@ class KotlinToResolvedCallTransformer( val candidate = baseResolvedCall.resultCallAtom!! when (baseResolvedCall.type) { CallResolutionResult.Type.PARTIAL -> { - context.trace.record(BindingContext.ONLY_RESOLVED_CALL, candidate.atom.psiKotlinCall.psiCall, baseResolvedCall) + val psiKotlinCall = candidate.atom.psiKotlinCall + val psiCall = if (psiKotlinCall is PSIKotlinCallForInvoke) + psiKotlinCall.baseCall.psiCall + else + psiKotlinCall.psiCall + + context.trace.record(BindingContext.ONLY_RESOLVED_CALL, psiCall, baseResolvedCall) return createStubResolvedCallAndWriteItToTrace(candidate, context.trace) }