Skip to content

Commit 0f2ee14

Browse files
committed
[CSFix] Add a specific kind for CollectionElementContextualMismatch
1 parent 152cf0b commit 0f2ee14

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/swift/Sema/CSFix.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ enum class FixKind : uint8_t {
365365
/// Ignore either capability (read/write) or type mismatch in conversion
366366
/// between two key path types.
367367
IgnoreKeyPathContextualMismatch,
368+
369+
/// Ignore a type mismatch between deduced element type and externally
370+
/// imposed one.
371+
IgnoreCollectionElementContextualMismatch,
368372
};
369373

370374
class ConstraintFix {
@@ -1845,7 +1849,9 @@ class RemoveReturn final : public ContextualMismatch {
18451849
class CollectionElementContextualMismatch final : public ContextualMismatch {
18461850
CollectionElementContextualMismatch(ConstraintSystem &cs, Type srcType,
18471851
Type dstType, ConstraintLocator *locator)
1848-
: ContextualMismatch(cs, srcType, dstType, locator) {}
1852+
: ContextualMismatch(cs,
1853+
FixKind::IgnoreCollectionElementContextualMismatch,
1854+
srcType, dstType, locator) {}
18491855

18501856
public:
18511857
std::string getName() const override {
@@ -1857,6 +1863,10 @@ class CollectionElementContextualMismatch final : public ContextualMismatch {
18571863
static CollectionElementContextualMismatch *
18581864
create(ConstraintSystem &cs, Type srcType, Type dstType,
18591865
ConstraintLocator *locator);
1866+
1867+
static bool classof(ConstraintFix *fix) {
1868+
return fix->getKind() == FixKind::IgnoreCollectionElementContextualMismatch;
1869+
}
18601870
};
18611871

18621872
class DefaultGenericArgument final : public ConstraintFix {

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11689,7 +11689,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1168911689
case FixKind::ContextualMismatch:
1169011690
case FixKind::IgnoreContextualType:
1169111691
case FixKind::IgnoreAssignmentDestinationType:
11692-
case FixKind::AllowConversionThroughInOut: {
11692+
case FixKind::AllowConversionThroughInOut:
11693+
case FixKind::IgnoreCollectionElementContextualMismatch: {
1169311694
auto impact = 1;
1169411695

1169511696
auto locator = fix->getLocator();

0 commit comments

Comments
 (0)