Skip to content

Commit 77626f4

Browse files
committed
[NFC] Add isKnownObjC param to RenamedDeclRequest
This will be used to break cycles in a future commit.
1 parent d0cf8bc commit 77626f4

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

include/swift/AST/Decl.h

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

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

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

include/swift/AST/TypeCheckRequests.h

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

36323632
class RenamedDeclRequest
36333633
: public SimpleRequest<RenamedDeclRequest,
3634-
ValueDecl *(const ValueDecl *, const AvailableAttr *),
3634+
ValueDecl *(const ValueDecl *, const AvailableAttr *,
3635+
bool isKnownObjC),
36353636
RequestFlags::Cached> {
36363637
public:
36373638
using SimpleRequest::SimpleRequest;
@@ -3640,7 +3641,7 @@ class RenamedDeclRequest
36403641
friend SimpleRequest;
36413642

36423643
ValueDecl *evaluate(Evaluator &evaluator, const ValueDecl *attached,
3643-
const AvailableAttr *attr) const;
3644+
const AvailableAttr *attr, bool isKnownObjC) const;
36443645

36453646
public:
36463647
bool isCached() const { return true; }

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ SWIFT_REQUEST(TypeChecker, GetImplicitSendableRequest,
423423
ProtocolConformance *(NominalTypeDecl *),
424424
Cached, NoLocationInfo)
425425
SWIFT_REQUEST(TypeChecker, RenamedDeclRequest,
426-
ValueDecl *(const ValueDecl *),
426+
ValueDecl *(const ValueDecl *, const AvailableAttr *, bool),
427427
Cached, NoLocationInfo)
428428
SWIFT_REQUEST(TypeChecker, ClosureEffectsRequest,
429429
FunctionType::ExtInfo(ClosureExpr *),

lib/AST/Decl.cpp

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

7591-
AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
7591+
AbstractFunctionDecl *
7592+
AbstractFunctionDecl::getAsyncAlternative(bool isKnownObjC) const {
75927593
// Async functions can't have async alternatives
75937594
if (hasAsync())
75947595
return nullptr;
@@ -7612,7 +7613,8 @@ AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
76127613
}
76137614

76147615
auto *renamedDecl = evaluateOrDefault(
7615-
getASTContext().evaluator, RenamedDeclRequest{this, avAttr}, nullptr);
7616+
getASTContext().evaluator, RenamedDeclRequest{this, avAttr, isKnownObjC},
7617+
nullptr);
76167618
auto *alternative = dyn_cast_or_null<AbstractFunctionDecl>(renamedDecl);
76177619
if (!alternative || !alternative->hasAsync())
76187620
return nullptr;

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,8 @@ class DeclAndTypePrinter::Implementation
10521052
assert(!AvAttr->Rename.empty());
10531053

10541054
auto *renamedDecl = evaluateOrDefault(
1055-
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr}, nullptr);
1055+
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr, false},
1056+
nullptr);
10561057
if (renamedDecl) {
10571058
assert(shouldInclude(renamedDecl) &&
10581059
"ObjC printer logic mismatch with renamed decl");

lib/Sema/TypeCheckAttr.cpp

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

61786178
ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
61796179
const ValueDecl *attached,
6180-
const AvailableAttr *attr) const {
6180+
const AvailableAttr *attr,
6181+
bool isKnownObjC) const {
61816182
if (!attached || !attr)
61826183
return nullptr;
61836184

@@ -6208,7 +6209,7 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
62086209
auto minAccess = AccessLevel::Private;
62096210
if (attached->getModuleContext()->isExternallyConsumed())
62106211
minAccess = AccessLevel::Public;
6211-
bool attachedIsObjcVisible =
6212+
bool attachedIsObjcVisible = isKnownObjC ||
62126213
objc_translation::isVisibleToObjC(attached, minAccess);
62136214

62146215
SmallVector<ValueDecl *, 4> lookupResults;

0 commit comments

Comments
 (0)