FIR: Refactor createExplicitReceiverForInvoke
This commit is contained in:
+18
-11
@@ -578,15 +578,10 @@ class FirTowerResolverSession internal constructor(
|
|||||||
!invokeBuiltinExtensionMode && isExtensionFunctionType &&
|
!invokeBuiltinExtensionMode && isExtensionFunctionType &&
|
||||||
invokeReceiverCandidate.explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
invokeReceiverCandidate.explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||||
|
|
||||||
val invokeReceiverExpression = components.createExplicitReceiverForInvoke(invokeReceiverCandidate).let {
|
val invokeReceiverExpression =
|
||||||
if (!invokeBuiltinExtensionMode) {
|
components.createExplicitReceiverForInvoke(
|
||||||
it.extensionReceiver = extensionReceiverExpression
|
invokeReceiverCandidate, info, invokeBuiltinExtensionMode, extensionReceiverExpression
|
||||||
// NB: this should fix problem in DFA (KT-36014)
|
)
|
||||||
it.explicitReceiver = info.explicitReceiver
|
|
||||||
it.safe = info.isSafeCall
|
|
||||||
}
|
|
||||||
components.transformQualifiedAccessUsingSmartcastInfo(it.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
val invokeFunctionInfo =
|
val invokeFunctionInfo =
|
||||||
info.copy(explicitReceiver = invokeReceiverExpression, name = OperatorNameConventions.INVOKE).let {
|
info.copy(explicitReceiver = invokeReceiverExpression, name = OperatorNameConventions.INVOKE).let {
|
||||||
@@ -687,7 +682,12 @@ class FirTowerResolverSession internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun BodyResolveComponents.createExplicitReceiverForInvoke(candidate: Candidate): FirQualifiedAccessExpressionBuilder {
|
private fun BodyResolveComponents.createExplicitReceiverForInvoke(
|
||||||
|
candidate: Candidate,
|
||||||
|
info: CallInfo,
|
||||||
|
invokeBuiltinExtensionMode: Boolean,
|
||||||
|
extensionReceiverExpression: FirExpression
|
||||||
|
): FirExpression {
|
||||||
val (name, typeRef) = when (val symbol = candidate.symbol) {
|
val (name, typeRef) = when (val symbol = candidate.symbol) {
|
||||||
is FirCallableSymbol<*> -> {
|
is FirCallableSymbol<*> -> {
|
||||||
symbol.callableId.callableName to returnTypeCalculator.tryCalculateReturnType(symbol.firUnsafe())
|
symbol.callableId.callableName to returnTypeCalculator.tryCalculateReturnType(symbol.firUnsafe())
|
||||||
@@ -707,5 +707,12 @@ private fun BodyResolveComponents.createExplicitReceiverForInvoke(candidate: Can
|
|||||||
)
|
)
|
||||||
dispatchReceiver = candidate.dispatchReceiverExpression()
|
dispatchReceiver = candidate.dispatchReceiverExpression()
|
||||||
this.typeRef = typeRef
|
this.typeRef = typeRef
|
||||||
}
|
|
||||||
|
if (!invokeBuiltinExtensionMode) {
|
||||||
|
extensionReceiver = extensionReceiverExpression
|
||||||
|
// NB: this should fix problem in DFA (KT-36014)
|
||||||
|
explicitReceiver = info.explicitReceiver
|
||||||
|
safe = info.isSafeCall
|
||||||
|
}
|
||||||
|
}.build().let(::transformQualifiedAccessUsingSmartcastInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user