Skip to content

Commit 2e5ab93

Browse files
committed
[CSFix] Add a specific kind for IgnoreContextualType
1 parent 04b35e4 commit 2e5ab93

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

include/swift/Sema/CSFix.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ enum class FixKind : uint8_t {
351351
/// Allow invalid pointer conversions for autoclosure result types as if the
352352
/// pointer type is a function parameter rather than an autoclosure result.
353353
AllowAutoClosurePointerConversion,
354+
355+
/// Ignore externally imposed type.
356+
IgnoreContextualType,
354357
};
355358

356359
class ConstraintFix {
@@ -1938,7 +1941,8 @@ class AllowTupleSplatForSingleParameter final : public ConstraintFix {
19381941
class IgnoreContextualType : public ContextualMismatch {
19391942
IgnoreContextualType(ConstraintSystem &cs, Type resultTy, Type specifiedTy,
19401943
ConstraintLocator *locator)
1941-
: ContextualMismatch(cs, resultTy, specifiedTy, locator) {}
1944+
: ContextualMismatch(cs, FixKind::IgnoreContextualType, resultTy,
1945+
specifiedTy, locator) {}
19421946

19431947
public:
19441948
std::string getName() const override {
@@ -1950,6 +1954,10 @@ class IgnoreContextualType : public ContextualMismatch {
19501954
static IgnoreContextualType *create(ConstraintSystem &cs, Type resultTy,
19511955
Type specifiedTy,
19521956
ConstraintLocator *locator);
1957+
1958+
static bool classof(ConstraintFix *fix) {
1959+
return fix->getKind() == FixKind::IgnoreContextualType;
1960+
}
19531961
};
19541962

19551963
class IgnoreAssignmentDestinationType final : public ContextualMismatch {

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11685,7 +11685,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1168511685
return matchTypes(*elemTy, dictionaryKeyTy, kind, subflags, elemLoc);
1168611686
}
1168711687

11688-
case FixKind::ContextualMismatch: {
11688+
case FixKind::ContextualMismatch:
11689+
case FixKind::IgnoreContextualType: {
1168911690
auto impact = 1;
1169011691

1169111692
auto locator = fix->getLocator();

0 commit comments

Comments
 (0)