[NI] Use only receiver from coroutine call to mark postponed variable
This commit is contained in:
+2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
@@ -31,6 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.model.CallableReferenceKotlinCallArgum
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.SimpleKotlinCallArgument
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class KotlinResolutionStatelessCallbacksImpl(
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ImplicitScopeTower
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.NonFixedType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
|
||||
+16
-8
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper.TypeArgumentsMapping.NoExplicitArguments
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
|
||||
@@ -192,17 +193,24 @@ internal object CreateFreshVariablesSubstitutor : ResolutionPart() {
|
||||
}
|
||||
}
|
||||
|
||||
internal object InferLaterInitializerResolutionPart : ResolutionPart() {
|
||||
internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
resolvedCall.argumentToCandidateParameter
|
||||
val typesForCoroutineCall = resolvedCall.argumentToCandidateParameter
|
||||
.filter { (argument, parameter) -> callComponents.statelessCallbacks.isCoroutineCall(argument, parameter) }
|
||||
.flatMap { (_, parameter) ->
|
||||
resolvedCall.substitutor.freshVariables.filter { variable ->
|
||||
parameter.type.contains { it.constructor == variable.originalTypeParameter.typeConstructor }
|
||||
}
|
||||
.mapNotNull { it.value.type.getReceiverTypeFromFunctionType() }
|
||||
|
||||
if (typesForCoroutineCall.isEmpty()) return
|
||||
|
||||
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
||||
val isPostponedVariable = typesForCoroutineCall.any { typeForCoroutineCall ->
|
||||
typeForCoroutineCall.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }
|
||||
}
|
||||
.distinct()
|
||||
.forEach { csBuilder.markPostponedVariable(it) }
|
||||
|
||||
if (isPostponedVariable) {
|
||||
csBuilder.markPostponedVariable(freshVariable)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -192,7 +192,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CreateFreshVariablesSubstitutor,
|
||||
CheckExplicitReceiverKindConsistency,
|
||||
CheckReceivers,
|
||||
InferLaterInitializerResolutionPart
|
||||
PostponedVariablesInitializerResolutionPart
|
||||
),
|
||||
FUNCTION(
|
||||
CheckInstantiationOfAbstractClass,
|
||||
@@ -207,7 +207,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckReceivers,
|
||||
CheckArguments,
|
||||
CheckExternalArgument,
|
||||
InferLaterInitializerResolutionPart
|
||||
PostponedVariablesInitializerResolutionPart
|
||||
),
|
||||
INVOKE(*FUNCTION.resolutionSequence.toTypedArray()),
|
||||
UNSUPPORTED();
|
||||
|
||||
Reference in New Issue
Block a user