[NI] Preserve annotations during type substitution
#KT-31346 Fixed
This commit is contained in:
+3
-3
@@ -53,14 +53,14 @@ class DelegatedPropertyInferenceSession(
|
||||
?: builtIns.nullableNothingType
|
||||
|
||||
val valueParameterForThis = descriptor.valueParameters.getOrNull(0) ?: return
|
||||
val substitutedType = substitutor.substituteKeepAnnotations(valueParameterForThis.type.unwrap())
|
||||
val substitutedType = substitutor.safeSubstitute(valueParameterForThis.type.unwrap())
|
||||
commonSystem.addSubtypeConstraint(typeOfThis.unwrap(), substitutedType, DelegatedPropertyConstraintPosition(atom))
|
||||
}
|
||||
|
||||
private fun ResolvedCallAtom.addConstraintsForGetValueMethod(commonSystem: ConstraintSystemBuilder) {
|
||||
if (expectedType != null) {
|
||||
val unsubstitutedReturnType = candidateDescriptor.returnType?.unwrap() ?: return
|
||||
val substitutedReturnType = substitutor.substituteKeepAnnotations(unsubstitutedReturnType)
|
||||
val substitutedReturnType = substitutor.safeSubstitute(unsubstitutedReturnType)
|
||||
|
||||
commonSystem.addSubtypeConstraint(substitutedReturnType, expectedType, DelegatedPropertyConstraintPosition(atom))
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class DelegatedPropertyInferenceSession(
|
||||
private fun ResolvedCallAtom.addConstraintsForSetValueMethod(commonSystem: ConstraintSystemBuilder) {
|
||||
if (expectedType != null) {
|
||||
val unsubstitutedParameterType = candidateDescriptor.valueParameters.getOrNull(2)?.type?.unwrap() ?: return
|
||||
val substitutedParameterType = substitutor.substituteKeepAnnotations(unsubstitutedParameterType)
|
||||
val substitutedParameterType = substitutor.safeSubstitute(unsubstitutedParameterType)
|
||||
|
||||
commonSystem.addSubtypeConstraint(expectedType, substitutedParameterType, DelegatedPropertyConstraintPosition(atom))
|
||||
}
|
||||
|
||||
+2
-1
@@ -91,6 +91,7 @@ class KotlinResolutionCallbacksImpl(
|
||||
receiverType: UnwrappedType?,
|
||||
parameters: List<UnwrappedType>,
|
||||
expectedReturnType: UnwrappedType?,
|
||||
annotations: Annotations,
|
||||
stubsForPostponedVariables: Map<NewTypeVariable, StubType>
|
||||
): Pair<List<KotlinCallArgument>, InferenceSession?> {
|
||||
val psiCallArgument = lambdaArgument.psiCallArgument as PSIFunctionKotlinCallArgument
|
||||
@@ -130,7 +131,7 @@ class KotlinResolutionCallbacksImpl(
|
||||
|
||||
val builtIns = outerCallContext.scope.ownerDescriptor.builtIns
|
||||
val expectedType = createFunctionType(
|
||||
builtIns, Annotations.EMPTY, receiverType, parameters, null,
|
||||
builtIns, annotations, receiverType, parameters, null,
|
||||
lambdaInfo.expectedType, isSuspend
|
||||
)
|
||||
|
||||
|
||||
+3
-3
@@ -191,8 +191,8 @@ class ResolvedAtomCompleter(
|
||||
val substitutedFunctionalType = createFunctionType(
|
||||
builtIns,
|
||||
existingLambdaType.annotations,
|
||||
lambda.receiver?.let { resultSubstitutor.substituteKeepAnnotations(it) },
|
||||
lambda.parameters.map { resultSubstitutor.substituteKeepAnnotations(it) },
|
||||
lambda.receiver?.let { resultSubstitutor.safeSubstitute(it) },
|
||||
lambda.parameters.map { resultSubstitutor.safeSubstitute(it) },
|
||||
null, // parameter names transforms to special annotations, so they are already taken from parameter types
|
||||
returnType,
|
||||
lambda.isSuspend
|
||||
@@ -208,7 +208,7 @@ class ResolvedAtomCompleter(
|
||||
}
|
||||
|
||||
val valueType = receiver.value.type.unwrap()
|
||||
val newValueType = resultSubstitutor.substituteKeepAnnotations(valueType)
|
||||
val newValueType = resultSubstitutor.safeSubstitute(valueType)
|
||||
|
||||
if (valueType !== newValueType) {
|
||||
val newReceiverValue = receiver.value.replaceType(newValueType)
|
||||
|
||||
Reference in New Issue
Block a user