Skip to content

Commit edbcf2e

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

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
@@ -6753,7 +6753,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
67536753
bool hasDynamicSelfResult() const;
67546754

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

67586758
/// If \p asyncAlternative is set, then compare its parameters to this
67596759
/// (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
@@ -3441,7 +3441,8 @@ class ConditionalRequirementsRequest
34413441

34423442
class RenamedDeclRequest
34433443
: public SimpleRequest<RenamedDeclRequest,
3444-
ValueDecl *(const ValueDecl *, const AvailableAttr *),
3444+
ValueDecl *(const ValueDecl *, const AvailableAttr *,
3445+
bool isKnownObjC),
34453446
RequestFlags::Cached> {
34463447
public:
34473448
using SimpleRequest::SimpleRequest;
@@ -3450,7 +3451,7 @@ class RenamedDeclRequest
34503451
friend SimpleRequest;
34513452

34523453
ValueDecl *evaluate(Evaluator &evaluator, const ValueDecl *attached,
3453-
const AvailableAttr *attr) const;
3454+
const AvailableAttr *attr, bool isKnownObjC) const;
34543455

34553456
public:
34563457
bool isCached() const { return true; }

include/swift/AST/TypeCheckerTypeIDZone.def

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

lib/AST/Decl.cpp

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

7630-
AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
7630+
AbstractFunctionDecl *
7631+
AbstractFunctionDecl::getAsyncAlternative(bool isKnownObjC) const {
76317632
// Async functions can't have async alternatives
76327633
if (hasAsync())
76337634
return nullptr;
@@ -7651,7 +7652,8 @@ AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
76517652
}
76527653

76537654
auto *renamedDecl = evaluateOrDefault(
7654-
getASTContext().evaluator, RenamedDeclRequest{this, avAttr}, nullptr);
7655+
getASTContext().evaluator, RenamedDeclRequest{this, avAttr, isKnownObjC},
7656+
nullptr);
76557657
auto *alternative = dyn_cast_or_null<AbstractFunctionDecl>(renamedDecl);
76567658
if (!alternative || !alternative->hasAsync())
76577659
return nullptr;

lib/PrintAsClang/DeclAndTypePrinter.cpp

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

10631063
auto *renamedDecl = evaluateOrDefault(
1064-
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr}, nullptr);
1064+
getASTContext().evaluator, RenamedDeclRequest{D, AvAttr, false},
1065+
nullptr);
10651066
if (renamedDecl) {
10661067
assert(shouldInclude(renamedDecl) &&
10671068
"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
@@ -6168,7 +6168,8 @@ static bool parametersMatch(const AbstractFunctionDecl *a,
61686168

61696169
ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
61706170
const ValueDecl *attached,
6171-
const AvailableAttr *attr) const {
6171+
const AvailableAttr *attr,
6172+
bool isKnownObjC) const {
61726173
if (!attached || !attr)
61736174
return nullptr;
61746175

@@ -6199,7 +6200,7 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
61996200
auto minAccess = AccessLevel::Private;
62006201
if (attached->getModuleContext()->isExternallyConsumed())
62016202
minAccess = AccessLevel::Public;
6202-
bool attachedIsObjcVisible =
6203+
bool attachedIsObjcVisible = isKnownObjC ||
62036204
objc_translation::isVisibleToObjC(attached, minAccess);
62046205

62056206
SmallVector<ValueDecl *, 4> lookupResults;

0 commit comments

Comments
 (0)