[NI] Keep track of fresh type variables created for particular call candidate
Otherwise we can't obtain inferred type arguments for the call, which is required for reification.
This commit is contained in:
committed by
Stanislav Erokhin
parent
eb7e9196b5
commit
13e8720ddc
+1
-6
@@ -350,12 +350,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
|
||||
override fun getTypeArguments(): Map<TypeParameterDescriptor, KotlinType> {
|
||||
val typeParameters = candidateDescriptor.typeParameters.takeIf { it.isNotEmpty() } ?: return emptyMap()
|
||||
|
||||
val result = HashMap<TypeParameterDescriptor, UnwrappedType>()
|
||||
for ((parameter, argument) in typeParameters.zip(completedCall.typeArguments)) {
|
||||
result[parameter] = argument
|
||||
}
|
||||
return result
|
||||
return typeParameters.zip(completedCall.typeArguments).toMap()
|
||||
}
|
||||
|
||||
override fun getSmartCastDispatchReceiverType(): KotlinType? = null // todo
|
||||
|
||||
+3
-1
@@ -121,7 +121,9 @@ class KotlinCallCompleter(
|
||||
descriptorWithFreshTypes
|
||||
}
|
||||
|
||||
val typeArguments = descriptorWithFreshTypes.typeParameters.map { substitutor.safeSubstitute(it.defaultType) }
|
||||
val typeArguments = descriptorWithFreshTypes.typeParameters.map {
|
||||
substitutor.safeSubstitute(typeVariablesForFreshTypeParameters[it.index].defaultType)
|
||||
}
|
||||
|
||||
val status = computeStatus(this, resultingDescriptor)
|
||||
return CompletedKotlinCall.Simple(kotlinCall, candidateDescriptor, resultingDescriptor, status, explicitReceiverKind,
|
||||
|
||||
+2
-1
@@ -102,7 +102,7 @@ internal object NoArguments : ResolutionPart {
|
||||
}
|
||||
}
|
||||
|
||||
internal object CreteDescriptorWithFreshTypeVariables : ResolutionPart {
|
||||
internal object CreateDescriptorWithFreshTypeVariables : ResolutionPart {
|
||||
override fun SimpleKotlinResolutionCandidate.process(): List<KotlinCallDiagnostic> {
|
||||
if (candidateDescriptor.typeParameters.isEmpty()) {
|
||||
descriptorWithFreshTypes = candidateDescriptor
|
||||
@@ -111,6 +111,7 @@ internal object CreteDescriptorWithFreshTypeVariables : ResolutionPart {
|
||||
val typeParameters = candidateDescriptor.typeParameters
|
||||
|
||||
val freshTypeVariables = typeParameters.map { TypeVariableFromCallableDescriptor(kotlinCall, it) }
|
||||
typeVariablesForFreshTypeParameters = freshTypeVariables
|
||||
val toFreshVariables = IndexedParametersSubstitution(typeParameters,
|
||||
freshTypeVariables.map { it.defaultType.asTypeProjection() }).buildSubstitutor()
|
||||
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckOperatorResolutionPart,
|
||||
NoTypeArguments,
|
||||
NoArguments,
|
||||
CreteDescriptorWithFreshTypeVariables,
|
||||
CreateDescriptorWithFreshTypeVariables,
|
||||
CheckExplicitReceiverKindConsistency,
|
||||
CheckReceivers
|
||||
),
|
||||
@@ -85,7 +85,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckVisibility,
|
||||
MapTypeArguments,
|
||||
MapArguments,
|
||||
CreteDescriptorWithFreshTypeVariables,
|
||||
CreateDescriptorWithFreshTypeVariables,
|
||||
CheckExplicitReceiverKindConsistency,
|
||||
CheckReceivers,
|
||||
CheckArguments
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMa
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.Candidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateStatus
|
||||
@@ -115,6 +116,7 @@ open class SimpleKotlinResolutionCandidate(
|
||||
lateinit var typeArgumentMappingByOriginal: TypeArgumentsToParametersMapper.TypeArgumentsMapping
|
||||
lateinit var argumentMappingByOriginal: Map<ValueParameterDescriptor, ResolvedCallArgument>
|
||||
lateinit var descriptorWithFreshTypes: CallableDescriptor
|
||||
lateinit var typeVariablesForFreshTypeParameters: List<NewTypeVariable>
|
||||
|
||||
override val lastCall: SimpleKotlinResolutionCandidate get() = this
|
||||
override val resolutionSequence: List<ResolutionPart> get() = kotlinCall.callKind.resolutionSequence
|
||||
|
||||
Reference in New Issue
Block a user