Skip to content

Commit 4f5b33b

Browse files
committed
[CSFix] Add a specific kind for IgnoreAssignmentDestinationType
1 parent 2e5ab93 commit 4f5b33b

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
@@ -354,6 +354,9 @@ enum class FixKind : uint8_t {
354354

355355
/// Ignore externally imposed type.
356356
IgnoreContextualType,
357+
358+
/// Ignore a type imposed by an assignment destination e.g. `let x: Int = ...`
359+
IgnoreAssignmentDestinationType,
357360
};
358361

359362
class ConstraintFix {
@@ -1963,7 +1966,8 @@ class IgnoreContextualType : public ContextualMismatch {
19631966
class IgnoreAssignmentDestinationType final : public ContextualMismatch {
19641967
IgnoreAssignmentDestinationType(ConstraintSystem &cs, Type sourceTy,
19651968
Type destTy, ConstraintLocator *locator)
1966-
: ContextualMismatch(cs, sourceTy, destTy, locator) {}
1969+
: ContextualMismatch(cs, FixKind::IgnoreAssignmentDestinationType,
1970+
sourceTy, destTy, locator) {}
19671971

19681972
public:
19691973
std::string getName() const override {
@@ -1977,6 +1981,10 @@ class IgnoreAssignmentDestinationType final : public ContextualMismatch {
19771981
static IgnoreAssignmentDestinationType *create(ConstraintSystem &cs,
19781982
Type sourceTy, Type destTy,
19791983
ConstraintLocator *locator);
1984+
1985+
static bool classof(ConstraintFix *fix) {
1986+
return fix->getKind() == FixKind::IgnoreAssignmentDestinationType;
1987+
}
19801988
};
19811989

19821990
/// If this is an argument-to-parameter conversion which is associated with

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11686,7 +11686,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1168611686
}
1168711687

1168811688
case FixKind::ContextualMismatch:
11689-
case FixKind::IgnoreContextualType: {
11689+
case FixKind::IgnoreContextualType:
11690+
case FixKind::IgnoreAssignmentDestinationType: {
1169011691
auto impact = 1;
1169111692

1169211693
auto locator = fix->getLocator();

0 commit comments

Comments
 (0)