[FIR] Check if type variable is bounded in upper by incompatible types (resolution stage)
This commit is contained in:
committed by
teamcity
parent
095a5d1fdf
commit
9474406375
@@ -20,7 +20,8 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckDslScopeViolation,
|
||||
CheckLowPriorityInOverloadResolution,
|
||||
PostponedVariablesInitializerResolutionStage,
|
||||
ConstraintSystemForks
|
||||
ConstraintSystemForks,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
object SyntheticSelect : CallKind(
|
||||
@@ -31,6 +32,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckArguments,
|
||||
EagerResolveOfCallableReferences,
|
||||
ConstraintSystemForks,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
object Function : CallKind(
|
||||
@@ -52,6 +54,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckLowPriorityInOverloadResolution,
|
||||
PostponedVariablesInitializerResolutionStage,
|
||||
ConstraintSystemForks,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
object DelegatingConstructorCall : CallKind(
|
||||
@@ -68,6 +71,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckArguments,
|
||||
EagerResolveOfCallableReferences,
|
||||
ConstraintSystemForks,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
object CallableReference : CallKind(
|
||||
@@ -82,6 +86,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckDslScopeViolation,
|
||||
CheckCallableReferenceExpectedType,
|
||||
CheckLowPriorityInOverloadResolution,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
object SyntheticIdForCallableReferencesResolution : CallKind(
|
||||
@@ -92,6 +97,7 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
||||
CheckArguments,
|
||||
EagerResolveOfCallableReferences,
|
||||
ConstraintSystemForks,
|
||||
CheckIncompatibleTypeVariableUpperBounds,
|
||||
)
|
||||
|
||||
internal class CustomForIde(vararg resolutionSequence: ResolutionStage) : CallKind(*resolutionSequence)
|
||||
|
||||
@@ -576,6 +576,27 @@ internal object CheckLowPriorityInOverloadResolution : CheckerStage() {
|
||||
}
|
||||
}
|
||||
|
||||
internal object CheckIncompatibleTypeVariableUpperBounds : ResolutionStage() {
|
||||
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) =
|
||||
with(candidate.system.asConstraintSystemCompleterContext()) {
|
||||
val typeVariables = candidate.system.notFixedTypeVariables.values
|
||||
|
||||
for (variableWithConstraints in typeVariables) {
|
||||
val upperTypes = variableWithConstraints.constraints.extractUpperTypes()
|
||||
|
||||
if (upperTypes.isEmptyIntersection()) {
|
||||
sink.yieldDiagnostic(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
InferredEmptyIntersectionDiagnostic(
|
||||
upperTypes as Collection<ConeKotlinType>,
|
||||
variableWithConstraints.typeVariable as ConeTypeVariable
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal object PostponedVariablesInitializerResolutionStage : ResolutionStage() {
|
||||
|
||||
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) {
|
||||
|
||||
Reference in New Issue
Block a user