From 1a288fcdcd775b161a31a009e6368cec6a7c4643 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 23 Nov 2021 15:49:38 +0300 Subject: [PATCH] FIR: Lookup contained postponed atoms recursively in delegate inference --- .../inference/FirDelegatedPropertyInferenceSession.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt index 1c2d93e6884..74dff3ae62b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirDelegatedPropertyInferenceSession.kt @@ -195,8 +195,15 @@ class FirDelegatedPropertyInferenceSession( notCompletedCalls as List, unitType, resolutionContext ) { lambdaAtom -> - val containingCandidateForLambda = notCompletedCalls.first { - it.candidate.postponedAtoms.contains(lambdaAtom) + // Reversed here bc we want top-most call to avoid exponential visit + val containingCandidateForLambda = notCompletedCalls.asReversed().first { + var found = false + it.processAllContainingCallCandidates(processBlocks = true) { subCandidate -> + if (subCandidate.postponedAtoms.contains(lambdaAtom)) { + found = true + } + } + found }.candidate postponedArgumentsAnalyzer.analyze( commonSystem.asPostponedArgumentsAnalyzerContext(),