From 64902e615ecd13f6b4aec46495c3734a1b857364 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Mon, 22 Jan 2024 18:48:53 +0100 Subject: [PATCH] K2: Minor. Unify call postponement rules in PCLA session --- .../resolve/inference/FirPCLAInferenceSession.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirPCLAInferenceSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirPCLAInferenceSession.kt index 94f0e80fc21..c99f60ff044 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirPCLAInferenceSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirPCLAInferenceSession.kt @@ -191,11 +191,17 @@ class FirPCLAInferenceSession( return Pair(coneTypeVariableTypeConstructor, resultType) } - private fun FirExpression.shouldBePostponed(): Boolean { - if (this is FirWrappedArgumentExpression) return expression.shouldBePostponed() + private fun FirExpression.doesArgumentLeadToCallPostponement(): Boolean { + if (this is FirWrappedArgumentExpression) return expression.doesArgumentLeadToCallPostponement() + + if (doesArgumentUseOuterCS()) return true + if (isQualifiedAccessContainingTypeVariables()) return true + + // Postponed atoms if (this is FirAnonymousFunctionExpression) return true if (this is FirCallableReferenceAccess) return true if (this is FirAnonymousObjectExpression) return true + return false } @@ -203,13 +209,12 @@ class FirPCLAInferenceSession( if (dispatchReceiver?.isReceiverPostponed() == true) return true if (givenExtensionReceiverOptions.any { it.isReceiverPostponed() }) return true - if (callInfo.arguments.any { it.shouldBePostponed() }) return true + if (callInfo.arguments.any { it.doesArgumentLeadToCallPostponement() }) return true if (callInfo.callKind == CallKind.VariableAccess) { val returnType = (symbol as? FirVariableSymbol)?.let(returnTypeCalculator::tryCalculateReturnType) if (returnType?.type?.containsNotFixedTypeVariables() == true) return true } - if (callInfo.arguments.any { it.isQualifiedAccessContainingTypeVariables() || it.doesArgumentUseOuterCS() }) return true if (callInfo.resolutionMode is ResolutionMode.Delegate) return true