[FE 1.0] Don't fail candidates which were marked with compatibility resolve previously
^KT-52431 Fixed ^KT-52393 Fixed
This commit is contained in:
committed by
teamcity
parent
73d676d9de
commit
02a430875f
+2
-1
@@ -152,7 +152,8 @@ class InferredEmptyIntersectionError(
|
||||
|
||||
class OnlyInputTypesDiagnostic(val typeVariable: TypeVariableMarker) : ConstraintSystemError(INAPPLICABLE)
|
||||
|
||||
object LowerPriorityToPreserveCompatibility : ConstraintSystemError(RESOLVED_NEED_PRESERVE_COMPATIBILITY)
|
||||
class LowerPriorityToPreserveCompatibility(val needToReportWarning: Boolean) :
|
||||
ConstraintSystemError(RESOLVED_NEED_PRESERVE_COMPATIBILITY)
|
||||
|
||||
fun Constraint.isExpectedTypePosition() =
|
||||
position.from is ExpectedTypeConstraintPosition<*> || position.from is DelegatedPropertyConstraintPosition<*>
|
||||
|
||||
+5
-1
@@ -450,9 +450,13 @@ class NewConstraintSystemImpl(
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.ForbidInferringTypeVariablesIntoEmptyIntersection)
|
||||
val upperTypes = intersectionTypeConstructor.supertypes()
|
||||
|
||||
// Diagnostic with these incompatible types has already been reported at the resolution stage
|
||||
if (upperTypes.size <= 1 || storage.errors.any { it is InferredEmptyIntersection && it.incompatibleTypes == upperTypes })
|
||||
return
|
||||
|
||||
if (upperTypes.computeEmptyIntersectionTypeKind().isDefinitelyEmpty()) {
|
||||
// Remove existing errors from resolution stage because a completion error is more precise
|
||||
storage.errors.removeIf { it is InferredEmptyIntersectionError || it is InferredEmptyIntersectionWarning }
|
||||
storage.errors.removeIf { it is InferredEmptyIntersection }
|
||||
val errorFactory =
|
||||
if (isInferredEmptyIntersectionForbidden) ::InferredEmptyIntersectionError else ::InferredEmptyIntersectionWarning
|
||||
addError(errorFactory(upperTypes, variable))
|
||||
|
||||
Reference in New Issue
Block a user