Skip to content

Commit 934e875

Browse files
committed
[CSFix] Add a specific kind for DropAsyncAttribute
1 parent d1d2846 commit 934e875

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

include/swift/Sema/CSFix.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ enum class FixKind : uint8_t {
343343
/// Fix conversion from throwing to non-throwing by removing explicit
344344
/// `throws` attribute from the source function.
345345
DropThrowsAttribute,
346+
347+
/// Fix conversion from async to sync function by removing explicit
348+
/// `async` attribute from the source function.
349+
DropAsyncAttribute,
346350
};
347351

348352
class ConstraintFix {
@@ -794,7 +798,8 @@ class DropThrowsAttribute final : public ContextualMismatch {
794798
class DropAsyncAttribute final : public ContextualMismatch {
795799
DropAsyncAttribute(ConstraintSystem &cs, FunctionType *fromType,
796800
FunctionType *toType, ConstraintLocator *locator)
797-
: ContextualMismatch(cs, fromType, toType, locator) {
801+
: ContextualMismatch(cs, FixKind::DropAsyncAttribute, fromType, toType,
802+
locator) {
798803
assert(fromType->isAsync() != toType->isAsync());
799804
}
800805

@@ -807,6 +812,10 @@ class DropAsyncAttribute final : public ContextualMismatch {
807812
FunctionType *fromType,
808813
FunctionType *toType,
809814
ConstraintLocator *locator);
815+
816+
static bool classof(ConstraintFix *fix) {
817+
return fix->getKind() == FixKind::DropAsyncAttribute;
818+
}
810819
};
811820

812821
/// Append 'as! T' to force a downcast to the specified type.

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11766,6 +11766,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1176611766
case FixKind::AddQualifierToAccessTopLevelName:
1176711767
case FixKind::AddSendableAttribute:
1176811768
case FixKind::DropThrowsAttribute:
11769+
case FixKind::DropAsyncAttribute:
1176911770
llvm_unreachable("handled elsewhere");
1177011771
}
1177111772

0 commit comments

Comments
 (0)