Fix order of fixing type variables for callable references. KT-25433 Fixed
This commit is contained in:
+9
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LHSArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableForLambdaReturnType
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
@@ -141,6 +142,14 @@ private fun preprocessCallableReference(
|
||||
|
||||
val notCallableTypeConstructor =
|
||||
csBuilder.getProperSuperTypeConstructors(expectedType).firstOrNull { !ReflectionTypes.isPossibleExpectedCallableType(it) }
|
||||
|
||||
argument.lhsResult.safeAs<LHSResult.Type>()?.let {
|
||||
val lhsType = it.unboundDetailedReceiver.stableType
|
||||
if (ReflectionTypes.isNumberedTypeWithOneOrMoreNumber(expectedType)) {
|
||||
val lhsTypeVariable = expectedType.arguments.first().type.unwrap()
|
||||
csBuilder.addSubtypeConstraint(lhsType, lhsTypeVariable, LHSArgumentConstraintPosition(it.qualifier))
|
||||
}
|
||||
}
|
||||
if (notCallableTypeConstructor != null) {
|
||||
diagnosticsHolder.addDiagnostic(NotCallableExpectedType(argument, expectedType, notCallableTypeConstructor))
|
||||
}
|
||||
|
||||
+7
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE_WRONG_RECEIVER
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
@@ -55,6 +56,12 @@ class KnownTypeParameterConstraintPosition(val typeArgument: KotlinType) : Const
|
||||
override fun toString() = "TypeArgument $typeArgument"
|
||||
}
|
||||
|
||||
class LHSArgumentConstraintPosition(val receiver: QualifierReceiver) : ConstraintPosition() {
|
||||
override fun toString(): String {
|
||||
return "LHS receiver $receiver"
|
||||
}
|
||||
}
|
||||
|
||||
class LambdaArgumentConstraintPosition(val lambda: ResolvedLambdaAtom) : ConstraintPosition() {
|
||||
override fun toString(): String {
|
||||
return "LambdaArgument $lambda"
|
||||
|
||||
Reference in New Issue
Block a user