Implement missing invoke resolution branch with context receivers
#KT-61937 fixed Note: the current implementation only resolves for a single receiver in each group. See KT-62712 and KT-62709 for the followup.
This commit is contained in:
committed by
Space Team
parent
b89d8a65a1
commit
268d058bbb
+16
@@ -443,6 +443,22 @@ private class InvokeFunctionResolveTask(
|
||||
ExplicitReceiverKind.DISPATCH_RECEIVER
|
||||
)
|
||||
}
|
||||
for ((depth, contextReceiverGroup) in towerDataElementsForName.contextReceiverGroups) {
|
||||
val towerGroup =
|
||||
TowerGroup
|
||||
.ContextReceiverGroup(depth)
|
||||
.InvokeExtensionWithImplicitReceiver
|
||||
.withGivenInvokeReceiverGroup(InvokeResolvePriority.INVOKE_EXTENSION)
|
||||
val towerLevel = invokeReceiverValue.toMemberScopeTowerLevel()
|
||||
// TODO: resolve for all receivers in the group, but implement the ambiguity diagnostics first. See KT-62712 and KT-69709
|
||||
contextReceiverGroup.singleOrNull()?.let { contextReceiverValue ->
|
||||
processLevel(
|
||||
towerLevel,
|
||||
info.withReceiverAsArgument(contextReceiverValue.receiverExpression), towerGroup,
|
||||
ExplicitReceiverKind.EXTENSION_RECEIVER
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun processLevelForRegularInvoke(
|
||||
|
||||
+6
-1
@@ -542,7 +542,12 @@ class BodyResolveContext(
|
||||
val forMembersResolution =
|
||||
statics
|
||||
.addLocalScope(parameterScope)
|
||||
.addContextReceiverGroup(towerElementsForScript.implicitReceivers)
|
||||
// TODO: temporary solution for avoiding problem described in KT-62712, flatten back after fix
|
||||
.let { baseCtx ->
|
||||
towerElementsForScript.implicitReceivers.fold(baseCtx) { ctx, it ->
|
||||
ctx.addContextReceiverGroup(listOf(it))
|
||||
}
|
||||
}
|
||||
|
||||
val newContexts = FirRegularTowerDataContexts(
|
||||
regular = forMembersResolution,
|
||||
|
||||
Reference in New Issue
Block a user