Skip to content

Commit 237ff4c

Browse files
authored
Merge pull request #60985 from DougGregor/simplify-getAsyncAlternative
Simplify get async alternative
2 parents ea21d32 + d3d09b7 commit 237ff4c

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
lines changed

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6825,7 +6825,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
68256825
bool hasDynamicSelfResult() const;
68266826

68276827
/// The async function marked as the alternative to this function, if any.
6828-
AbstractFunctionDecl *getAsyncAlternative(bool isKnownObjC = false) const;
6828+
AbstractFunctionDecl *getAsyncAlternative() const;
68296829

68306830
/// If \p asyncAlternative is set, then compare its parameters to this
68316831
/// (presumed synchronous) function's parameters to find the index of the

include/swift/AST/TypeCheckRequests.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,8 +3455,7 @@ class ConditionalRequirementsRequest
34553455

34563456
class RenamedDeclRequest
34573457
: public SimpleRequest<RenamedDeclRequest,
3458-
ValueDecl *(const ValueDecl *, const AvailableAttr *,
3459-
bool isKnownObjC),
3458+
ValueDecl *(const ValueDecl *, const AvailableAttr *),
34603459
RequestFlags::Cached> {
34613460
public:
34623461
using SimpleRequest::SimpleRequest;
@@ -3465,7 +3464,7 @@ class RenamedDeclRequest
34653464
friend SimpleRequest;
34663465

34673466
ValueDecl *evaluate(Evaluator &evaluator, const ValueDecl *attached,
3468-
const AvailableAttr *attr, bool isKnownObjC) const;
3467+
const AvailableAttr *attr) const;
34693468

34703469
public:
34713470
bool isCached() const { return true; }

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ SWIFT_REQUEST(TypeChecker, GetImplicitSendableRequest,
391391
ProtocolConformance *(NominalTypeDecl *),
392392
Cached, NoLocationInfo)
393393
SWIFT_REQUEST(TypeChecker, RenamedDeclRequest,
394-
ValueDecl *(const ValueDecl *, const AvailableAttr *, bool),
394+
ValueDecl *(const ValueDecl *, const AvailableAttr *),
395395
Cached, NoLocationInfo)
396396
SWIFT_REQUEST(TypeChecker, ClosureEffectsRequest,
397397
FunctionType::ExtInfo(ClosureExpr *),

lib/AST/Decl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7668,8 +7668,7 @@ bool AbstractFunctionDecl::hasDynamicSelfResult() const {
76687668
return isa<ConstructorDecl>(this);
76697669
}
76707670

7671-
AbstractFunctionDecl *
7672-
AbstractFunctionDecl::getAsyncAlternative(bool isKnownObjC) const {
7671+
AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
76737672
// Async functions can't have async alternatives
76747673
if (hasAsync())
76757674
return nullptr;
@@ -7693,8 +7692,7 @@ AbstractFunctionDecl::getAsyncAlternative(bool isKnownObjC) const {
76937692
}
76947693

76957694
auto *renamedDecl = evaluateOrDefault(
7696-
getASTContext().evaluator, RenamedDeclRequest{this, avAttr, isKnownObjC},
7697-
nullptr);
7695+
getASTContext().evaluator, RenamedDeclRequest{this, avAttr}, nullptr);
76987696
auto *alternative = dyn_cast_or_null<AbstractFunctionDecl>(renamedDecl);
76997697
if (!alternative || !alternative->hasAsync())
77007698
return nullptr;

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,8 +1547,7 @@ class DeclAndTypePrinter::Implementation
15471547
assert(!AvAttr->Rename.empty());
15481548

15491549
auto *renamedDecl = evaluateOrDefault(
1550-
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr, false},
1551-
nullptr);
1550+
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr}, nullptr);
15521551
if (renamedDecl) {
15531552
assert(shouldInclude(renamedDecl) &&
15541553
"ObjC printer logic mismatch with renamed decl");

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6676,8 +6676,7 @@ static bool parametersMatch(const AbstractFunctionDecl *a,
66766676

66776677
ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
66786678
const ValueDecl *attached,
6679-
const AvailableAttr *attr,
6680-
bool isKnownObjC) const {
6679+
const AvailableAttr *attr) const {
66816680
if (!attached || !attr)
66826681
return nullptr;
66836682

@@ -6708,7 +6707,7 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
67086707
auto minAccess = AccessLevel::Private;
67096708
if (attached->getModuleContext()->isExternallyConsumed())
67106709
minAccess = AccessLevel::Public;
6711-
bool attachedIsObjcVisible = isKnownObjC ||
6710+
bool attachedIsObjcVisible =
67126711
objc_translation::isVisibleToObjC(attached, minAccess);
67136712

67146713
SmallVector<ValueDecl *, 4> lookupResults;

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ getObjCMethodConflictDecls(const SourceFile::ObjCMethodConflict &conflict) {
24532453
asyncAlternatives;
24542454
for (auto method : methods) {
24552455
if (isa<ProtocolDecl>(method->getDeclContext())) {
2456-
if (auto alt = method->getAsyncAlternative(/*isKnownObjC=*/true))
2456+
if (auto alt = method->getAsyncAlternative())
24572457
asyncAlternatives[method] = alt;
24582458
}
24592459
}

0 commit comments

Comments
 (0)