Skip to content

Commit 04b35e4

Browse files
committed
[CSFix] Add a specific kind for AllowAutoClosurePointerConversion
1 parent 934e875 commit 04b35e4

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

include/swift/Sema/CSFix.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ enum class FixKind : uint8_t {
347347
/// Fix conversion from async to sync function by removing explicit
348348
/// `async` attribute from the source function.
349349
DropAsyncAttribute,
350+
351+
/// Allow invalid pointer conversions for autoclosure result types as if the
352+
/// pointer type is a function parameter rather than an autoclosure result.
353+
AllowAutoClosurePointerConversion,
350354
};
351355

352356
class ConstraintFix {
@@ -982,12 +986,12 @@ class AutoClosureForwarding final : public ConstraintFix {
982986
}
983987
};
984988

985-
/// Allow invalid pointer conversions for autoclosure result types as if the
986-
/// pointer type is a function parameter rather than an autoclosure result.
987989
class AllowAutoClosurePointerConversion final : public ContextualMismatch {
988990
AllowAutoClosurePointerConversion(ConstraintSystem &cs, Type pointeeType,
989-
Type pointerType, ConstraintLocator *locator)
990-
: ContextualMismatch(cs, pointeeType, pointerType, locator) {}
991+
Type pointerType,
992+
ConstraintLocator *locator)
993+
: ContextualMismatch(cs, FixKind::AllowAutoClosurePointerConversion,
994+
pointeeType, pointerType, locator) {}
991995

992996
public:
993997
std::string getName() const override {
@@ -1000,6 +1004,10 @@ class AllowAutoClosurePointerConversion final : public ContextualMismatch {
10001004
Type pointeeType,
10011005
Type pointerType,
10021006
ConstraintLocator *locator);
1007+
1008+
static bool classof(ConstraintFix *fix) {
1009+
return fix->getKind() == FixKind::AllowAutoClosurePointerConversion;
1010+
}
10031011
};
10041012

10051013
class RemoveUnwrap final : public ConstraintFix {

lib/Sema/CSSimplify.cpp

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

0 commit comments

Comments
 (0)