diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 63e080d5868..e801a3062b0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -534,9 +534,16 @@ class FirCallCompletionResultsWriterTransformer( syntheticCall: D, data: ExpectedArgumentType?, ): CompositeTransformResult where D : FirResolvable, D : FirExpression { - val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate ?: return syntheticCall.compose() + val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate + val declaration = calleeReference?.candidate?.symbol?.fir as? FirSimpleFunction - val declaration = calleeReference.candidate.symbol.fir as? FirSimpleFunction ?: return syntheticCall.compose() + if (calleeReference == null || declaration == null) { + syntheticCall.transformChildren( + this, + data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() + ) + return syntheticCall.compose() + } val typeRef = typeCalculator.tryCalculateReturnType(declaration) syntheticCall.replaceTypeRefWithSubstituted(calleeReference, typeRef) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt index 4657de5aa65..5e8254c4013 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt @@ -5,7 +5,7 @@ fun materialize(): M = TODO() fun test(b: Boolean) { id(if (b) { - id(unresolved) + id(unresolved) } else { id( materialize()