Skip to content

Commit 48cdb58

Browse files
committed
[CSFix] Add a specific kind for AllowInOutConversion
1 parent 4f5b33b commit 48cdb58

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
@@ -357,6 +357,10 @@ enum class FixKind : uint8_t {
357357

358358
/// Ignore a type imposed by an assignment destination e.g. `let x: Int = ...`
359359
IgnoreAssignmentDestinationType,
360+
361+
/// Allow argument-to-parameter subtyping even when parameter type
362+
/// is marked as `inout`.
363+
AllowConversionThroughInOut,
360364
};
361365

362366
class ConstraintFix {
@@ -1993,7 +1997,8 @@ class IgnoreAssignmentDestinationType final : public ContextualMismatch {
19931997
class AllowInOutConversion final : public ContextualMismatch {
19941998
AllowInOutConversion(ConstraintSystem &cs, Type argType, Type paramType,
19951999
ConstraintLocator *locator)
1996-
: ContextualMismatch(cs, argType, paramType, locator) {}
2000+
: ContextualMismatch(cs, FixKind::AllowConversionThroughInOut, argType,
2001+
paramType, locator) {}
19972002

19982003
public:
19992004
std::string getName() const override {
@@ -2005,6 +2010,10 @@ class AllowInOutConversion final : public ContextualMismatch {
20052010
static AllowInOutConversion *create(ConstraintSystem &cs, Type argType,
20062011
Type paramType,
20072012
ConstraintLocator *locator);
2013+
2014+
static bool classof(ConstraintFix *fix) {
2015+
return fix->getKind() == FixKind::AllowConversionThroughInOut;
2016+
}
20082017
};
20092018

20102019
class AllowArgumentMismatch : public ContextualMismatch {

lib/Sema/CSSimplify.cpp

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

1168811688
case FixKind::ContextualMismatch:
1168911689
case FixKind::IgnoreContextualType:
11690-
case FixKind::IgnoreAssignmentDestinationType: {
11690+
case FixKind::IgnoreAssignmentDestinationType:
11691+
case FixKind::AllowConversionThroughInOut: {
1169111692
auto impact = 1;
1169211693

1169311694
auto locator = fix->getLocator();

0 commit comments

Comments
 (0)