Skip to content

Commit 152cf0b

Browse files
committed
[CSFix] Add a specific kind for IgnoreKeyPathContextualMismatch
1 parent 48cdb58 commit 152cf0b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/swift/Sema/CSFix.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ enum class FixKind : uint8_t {
361361
/// Allow argument-to-parameter subtyping even when parameter type
362362
/// is marked as `inout`.
363363
AllowConversionThroughInOut,
364+
365+
/// Ignore either capability (read/write) or type mismatch in conversion
366+
/// between two key path types.
367+
IgnoreKeyPathContextualMismatch,
364368
};
365369

366370
class ConstraintFix {
@@ -958,7 +962,8 @@ class GenericArgumentsMismatch final
958962
class KeyPathContextualMismatch final : public ContextualMismatch {
959963
KeyPathContextualMismatch(ConstraintSystem &cs, Type lhs, Type rhs,
960964
ConstraintLocator *locator)
961-
: ContextualMismatch(cs, lhs, rhs, locator) {}
965+
: ContextualMismatch(cs, FixKind::IgnoreKeyPathContextualMismatch, lhs,
966+
rhs, locator) {}
962967

963968
public:
964969
std::string getName() const override {
@@ -967,6 +972,10 @@ class KeyPathContextualMismatch final : public ContextualMismatch {
967972

968973
static KeyPathContextualMismatch *
969974
create(ConstraintSystem &cs, Type lhs, Type rhs, ConstraintLocator *locator);
975+
976+
static bool classof(ConstraintFix *fix) {
977+
return fix->getKind() == FixKind::IgnoreKeyPathContextualMismatch;
978+
}
970979
};
971980

972981
/// Detect situations when argument of the @autoclosure parameter is itself

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11564,7 +11564,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1156411564
case FixKind::AllowWrappedValueMismatch:
1156511565
case FixKind::RemoveExtraneousArguments:
1156611566
case FixKind::SpecifyTypeForPlaceholder:
11567-
case FixKind::AllowAutoClosurePointerConversion: {
11567+
case FixKind::AllowAutoClosurePointerConversion:
11568+
case FixKind::IgnoreKeyPathContextualMismatch: {
1156811569
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
1156911570
}
1157011571

0 commit comments

Comments
 (0)