Use proper applicability for constraint warnings
^KT-47316 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
1224d28deb
commit
c3a5a7754d
+18
-6
@@ -91,12 +91,24 @@ object SimpleConstraintSystemConstraintPosition : ConstraintPosition()
|
||||
|
||||
sealed class ConstraintSystemError(val applicability: CandidateApplicability)
|
||||
|
||||
sealed interface NewConstraintMismatch {
|
||||
val lowerType: KotlinTypeMarker
|
||||
val upperType: KotlinTypeMarker
|
||||
val position: IncorporationConstraintPosition
|
||||
}
|
||||
|
||||
class NewConstraintError(
|
||||
val lowerType: KotlinTypeMarker,
|
||||
val upperType: KotlinTypeMarker,
|
||||
val position: IncorporationConstraintPosition,
|
||||
val isWarning: Boolean = false
|
||||
) : ConstraintSystemError(if (position.from is ReceiverConstraintPosition<*>) INAPPLICABLE_WRONG_RECEIVER else INAPPLICABLE)
|
||||
override val lowerType: KotlinTypeMarker,
|
||||
override val upperType: KotlinTypeMarker,
|
||||
override val position: IncorporationConstraintPosition,
|
||||
) : ConstraintSystemError(if (position.from is ReceiverConstraintPosition<*>) INAPPLICABLE_WRONG_RECEIVER else INAPPLICABLE),
|
||||
NewConstraintMismatch
|
||||
|
||||
class NewConstraintWarning(
|
||||
override val lowerType: KotlinTypeMarker,
|
||||
override val upperType: KotlinTypeMarker,
|
||||
override val position: IncorporationConstraintPosition,
|
||||
) : ConstraintSystemError(RESOLVED), NewConstraintMismatch
|
||||
|
||||
class CapturedTypeFromSubtyping(
|
||||
val typeVariable: TypeVariableMarker,
|
||||
@@ -122,4 +134,4 @@ object LowerPriorityToPreserveCompatibility : ConstraintSystemError(RESOLVED_NEE
|
||||
fun Constraint.isExpectedTypePosition() =
|
||||
position.from is ExpectedTypeConstraintPosition<*> || position.from is DelegatedPropertyConstraintPosition<*>
|
||||
|
||||
fun NewConstraintError.transformToWarning() = NewConstraintError(lowerType, upperType, position, isWarning = true)
|
||||
fun NewConstraintError.transformToWarning() = NewConstraintWarning(lowerType, upperType, position)
|
||||
|
||||
+1
-1
@@ -386,7 +386,7 @@ class NewConstraintSystemImpl(
|
||||
}
|
||||
val constraintErrors = constraintSystem.errors.filterIsInstance<NewConstraintError>()
|
||||
// Don't report warning if an error on the same call has already been reported
|
||||
if (constraintErrors.isEmpty() || constraintErrors.all { it.isWarning }) {
|
||||
if (constraintErrors.isEmpty()) {
|
||||
errorsByMissedConstraints.forEach {
|
||||
constraintSystem.addError(it.transformToWarning())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user