FE: don't run overload-by-lambda-return-type with unsuccessful candidates

Related to KT-52927
This commit is contained in:
Mikhail Glukhikh
2022-09-09 16:16:22 +02:00
committed by teamcity
parent 046f0ad95d
commit 393e99fa44
2 changed files with 4 additions and 2 deletions
@@ -95,6 +95,7 @@ class FirOverloadByLambdaReturnTypeResolver(
call: T,
candidates: Set<Candidate>,
): Set<Candidate>? where T : FirResolvable, T : FirStatement {
if (candidates.any { !it.isSuccessful }) return candidates
val lambdas = candidates.flatMap { candidate ->
candidate.postponedAtoms
.filter { it is ResolvedLambdaAtom && !it.analyzed }
@@ -244,8 +244,9 @@ class KotlinCallResolver(
}
}
if (callComponents.languageVersionSettings.supportsFeature(LanguageFeature.OverloadResolutionByLambdaReturnType) &&
candidates.all { resolutionCallbacks.inferenceSession.shouldRunCompletion(it) } &&
kotlinCall.callKind != KotlinCallKind.CALLABLE_REFERENCE
kotlinCall.callKind != KotlinCallKind.CALLABLE_REFERENCE &&
candidates.all { it.isSuccessful } &&
candidates.all { resolutionCallbacks.inferenceSession.shouldRunCompletion(it) }
) {
val candidatesWithAnnotation = candidates.filter {
it.resolvedCall.candidateDescriptor.annotations.hasAnnotation(OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION_FQ_NAME)