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(),