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 07350b79d33..f2f93c05862 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 @@ -555,19 +555,13 @@ class FirCallCompletionResultsWriterTransformer( val declaration = calleeReference?.candidate?.symbol?.fir as? FirSimpleFunction if (calleeReference == null || declaration == null) { - syntheticCall.transformChildren( - this, - data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() - ) + transformSyntheticCallChildren(syntheticCall, data) return syntheticCall.compose() } val typeRef = typeCalculator.tryCalculateReturnType(declaration) syntheticCall.replaceTypeRefWithSubstituted(calleeReference, typeRef) - syntheticCall.transformChildren( - this, - data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() - ) + transformSyntheticCallChildren(syntheticCall, data) return (syntheticCall.transformCalleeReference( StoreCalleeReference, @@ -575,6 +569,25 @@ class FirCallCompletionResultsWriterTransformer( ) as D).compose() } + private inline fun transformSyntheticCallChildren( + syntheticCall: D, + data: ExpectedArgumentType? + ) where D : FirResolvable, D : FirExpression { + val newData = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() + + if (syntheticCall is FirTryExpression) { + syntheticCall.transformCalleeReference(this, newData) + syntheticCall.transformTryBlock(this, newData) + syntheticCall.transformCatches(this, newData) + return + } + + syntheticCall.transformChildren( + this, + data = newData + ) + } + override fun transformConstExpression( constExpression: FirConstExpression, data: ExpectedArgumentType?,