mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Remove unused LazyResolver parameter from ObjC-selector-related Decl methods
This commit is contained in:
@@ -4333,13 +4333,13 @@ public:
|
|||||||
|
|
||||||
/// Given that this is an Objective-C property or subscript declaration,
|
/// Given that this is an Objective-C property or subscript declaration,
|
||||||
/// produce its getter selector.
|
/// produce its getter selector.
|
||||||
ObjCSelector getObjCGetterSelector(LazyResolver *resolver = nullptr,
|
ObjCSelector
|
||||||
Identifier preferredName = Identifier()) const;
|
getObjCGetterSelector(Identifier preferredName = Identifier()) const;
|
||||||
|
|
||||||
/// Given that this is an Objective-C property or subscript declaration,
|
/// Given that this is an Objective-C property or subscript declaration,
|
||||||
/// produce its setter selector.
|
/// produce its setter selector.
|
||||||
ObjCSelector getObjCSetterSelector(LazyResolver *resolver = nullptr,
|
ObjCSelector
|
||||||
Identifier preferredName = Identifier()) const;
|
getObjCSetterSelector(Identifier preferredName = Identifier()) const;
|
||||||
|
|
||||||
AbstractStorageDecl *getOverriddenDecl() const {
|
AbstractStorageDecl *getOverriddenDecl() const {
|
||||||
return OverriddenDecl;
|
return OverriddenDecl;
|
||||||
@@ -4835,7 +4835,7 @@ public:
|
|||||||
|
|
||||||
/// Determine the kind of Objective-C subscripting this declaration
|
/// Determine the kind of Objective-C subscripting this declaration
|
||||||
/// implies.
|
/// implies.
|
||||||
ObjCSubscriptKind getObjCSubscriptKind(LazyResolver *resolver) const;
|
ObjCSubscriptKind getObjCSubscriptKind() const;
|
||||||
|
|
||||||
SubscriptDecl *getOverriddenDecl() const {
|
SubscriptDecl *getOverriddenDecl() const {
|
||||||
return cast_or_null<SubscriptDecl>(
|
return cast_or_null<SubscriptDecl>(
|
||||||
@@ -5121,8 +5121,7 @@ public:
|
|||||||
const CaptureInfo &getCaptureInfo() const { return Captures; }
|
const CaptureInfo &getCaptureInfo() const { return Captures; }
|
||||||
|
|
||||||
/// Retrieve the Objective-C selector that names this method.
|
/// Retrieve the Objective-C selector that names this method.
|
||||||
ObjCSelector getObjCSelector(LazyResolver *resolver = nullptr,
|
ObjCSelector getObjCSelector(DeclName preferredName = DeclName()) const;
|
||||||
DeclName preferredName = DeclName()) const;
|
|
||||||
|
|
||||||
/// Determine whether the given method would produce an Objective-C
|
/// Determine whether the given method would produce an Objective-C
|
||||||
/// instance method.
|
/// instance method.
|
||||||
|
|||||||
@@ -2515,7 +2515,7 @@ bool ASTContext::diagnoseUnintendedObjCMethodOverrides(SourceFile &sf) {
|
|||||||
// Note: This should be treated as a lookup for intra-module dependency
|
// Note: This should be treated as a lookup for intra-module dependency
|
||||||
// purposes, but a subclass already depends on its superclasses and any
|
// purposes, but a subclass already depends on its superclasses and any
|
||||||
// extensions for many other reasons.
|
// extensions for many other reasons.
|
||||||
auto selector = method->getObjCSelector(nullptr);
|
auto selector = method->getObjCSelector();
|
||||||
AbstractFunctionDecl *overriddenMethod
|
AbstractFunctionDecl *overriddenMethod
|
||||||
= lookupObjCMethodInType(classDecl->getSuperclass(),
|
= lookupObjCMethodInType(classDecl->getSuperclass(),
|
||||||
selector,
|
selector,
|
||||||
|
|||||||
@@ -3908,8 +3908,8 @@ getNameFromObjcAttribute(const ObjCAttr *attr, DeclName preferredName) {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCSelector AbstractStorageDecl::getObjCGetterSelector(
|
ObjCSelector
|
||||||
LazyResolver *resolver, Identifier preferredName) const {
|
AbstractStorageDecl::getObjCGetterSelector(Identifier preferredName) const {
|
||||||
// If the getter has an @objc attribute with a name, use that.
|
// If the getter has an @objc attribute with a name, use that.
|
||||||
if (auto getter = getGetter()) {
|
if (auto getter = getGetter()) {
|
||||||
if (auto name = getNameFromObjcAttribute(getter->getAttrs().
|
if (auto name = getNameFromObjcAttribute(getter->getAttrs().
|
||||||
@@ -3920,7 +3920,7 @@ ObjCSelector AbstractStorageDecl::getObjCGetterSelector(
|
|||||||
// Subscripts use a specific selector.
|
// Subscripts use a specific selector.
|
||||||
auto &ctx = getASTContext();
|
auto &ctx = getASTContext();
|
||||||
if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
|
if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
|
||||||
switch (SD->getObjCSubscriptKind(resolver)) {
|
switch (SD->getObjCSubscriptKind()) {
|
||||||
case ObjCSubscriptKind::None:
|
case ObjCSubscriptKind::None:
|
||||||
llvm_unreachable("Not an Objective-C subscript");
|
llvm_unreachable("Not an Objective-C subscript");
|
||||||
case ObjCSubscriptKind::Indexed:
|
case ObjCSubscriptKind::Indexed:
|
||||||
@@ -3940,8 +3940,8 @@ ObjCSelector AbstractStorageDecl::getObjCGetterSelector(
|
|||||||
return VarDecl::getDefaultObjCGetterSelector(ctx, name);
|
return VarDecl::getDefaultObjCGetterSelector(ctx, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCSelector AbstractStorageDecl::getObjCSetterSelector(
|
ObjCSelector
|
||||||
LazyResolver *resolver, Identifier preferredName) const {
|
AbstractStorageDecl::getObjCSetterSelector(Identifier preferredName) const {
|
||||||
// If the setter has an @objc attribute with a name, use that.
|
// If the setter has an @objc attribute with a name, use that.
|
||||||
auto setter = getSetter();
|
auto setter = getSetter();
|
||||||
auto objcAttr = setter ? setter->getAttrs().getAttribute<ObjCAttr>()
|
auto objcAttr = setter ? setter->getAttrs().getAttribute<ObjCAttr>()
|
||||||
@@ -3953,7 +3953,7 @@ ObjCSelector AbstractStorageDecl::getObjCSetterSelector(
|
|||||||
// Subscripts use a specific selector.
|
// Subscripts use a specific selector.
|
||||||
auto &ctx = getASTContext();
|
auto &ctx = getASTContext();
|
||||||
if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
|
if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
|
||||||
switch (SD->getObjCSubscriptKind(resolver)) {
|
switch (SD->getObjCSubscriptKind()) {
|
||||||
case ObjCSubscriptKind::None:
|
case ObjCSubscriptKind::None:
|
||||||
llvm_unreachable("Not an Objective-C subscript");
|
llvm_unreachable("Not an Objective-C subscript");
|
||||||
|
|
||||||
@@ -4554,8 +4554,7 @@ Type SubscriptDecl::getElementInterfaceType() const {
|
|||||||
return elementTy->castTo<AnyFunctionType>()->getResult();
|
return elementTy->castTo<AnyFunctionType>()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCSubscriptKind SubscriptDecl::getObjCSubscriptKind(
|
ObjCSubscriptKind SubscriptDecl::getObjCSubscriptKind() const {
|
||||||
LazyResolver *resolver) const {
|
|
||||||
auto indexTy = getIndicesInterfaceType();
|
auto indexTy = getIndicesInterfaceType();
|
||||||
|
|
||||||
// Look through a named 1-tuple.
|
// Look through a named 1-tuple.
|
||||||
@@ -4741,8 +4740,8 @@ SourceRange AbstractFunctionDecl::getSignatureSourceRange() const {
|
|||||||
return getNameLoc();
|
return getNameLoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCSelector AbstractFunctionDecl::getObjCSelector(
|
ObjCSelector
|
||||||
LazyResolver *resolver, DeclName preferredName) const {
|
AbstractFunctionDecl::getObjCSelector(DeclName preferredName) const {
|
||||||
// If there is an @objc attribute with a name, use that name.
|
// If there is an @objc attribute with a name, use that name.
|
||||||
auto *objc = getAttrs().getAttribute<ObjCAttr>();
|
auto *objc = getAttrs().getAttribute<ObjCAttr>();
|
||||||
if (auto name = getNameFromObjcAttribute(objc, preferredName)) {
|
if (auto name = getNameFromObjcAttribute(objc, preferredName)) {
|
||||||
@@ -4780,9 +4779,9 @@ ObjCSelector AbstractFunctionDecl::getObjCSelector(
|
|||||||
// For a getter or setter, go through the variable or subscript decl.
|
// For a getter or setter, go through the variable or subscript decl.
|
||||||
auto asd = accessor->getStorage();
|
auto asd = accessor->getStorage();
|
||||||
if (accessor->isGetter())
|
if (accessor->isGetter())
|
||||||
return asd->getObjCGetterSelector(resolver, baseName);
|
return asd->getObjCGetterSelector(baseName);
|
||||||
if (accessor->isSetter())
|
if (accessor->isSetter())
|
||||||
return asd->getObjCSetterSelector(resolver, baseName);
|
return asd->getObjCSetterSelector(baseName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a zero-parameter initializer with a long selector
|
// If this is a zero-parameter initializer with a long selector
|
||||||
|
|||||||
@@ -73,9 +73,8 @@ printSwiftEnumElemNameInObjC(const EnumElementDecl *EL, llvm::raw_ostream &OS,
|
|||||||
std::pair<Identifier, ObjCSelector> swift::objc_translation::
|
std::pair<Identifier, ObjCSelector> swift::objc_translation::
|
||||||
getObjCNameForSwiftDecl(const ValueDecl *VD, DeclName PreferredName){
|
getObjCNameForSwiftDecl(const ValueDecl *VD, DeclName PreferredName){
|
||||||
ASTContext &Ctx = VD->getASTContext();
|
ASTContext &Ctx = VD->getASTContext();
|
||||||
LazyResolver *Resolver = Ctx.getLazyResolver();
|
|
||||||
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
|
if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD)) {
|
||||||
return {Identifier(), FD->getObjCSelector(Resolver, PreferredName)};
|
return {Identifier(), FD->getObjCSelector(PreferredName)};
|
||||||
} else if (auto *VAD = dyn_cast<VarDecl>(VD)) {
|
} else if (auto *VAD = dyn_cast<VarDecl>(VD)) {
|
||||||
if (PreferredName)
|
if (PreferredName)
|
||||||
return {PreferredName.getBaseIdentifier(), ObjCSelector()};
|
return {PreferredName.getBaseIdentifier(), ObjCSelector()};
|
||||||
|
|||||||
@@ -2627,7 +2627,7 @@ static void inferObjCName(TypeChecker &tc, ValueDecl *decl) {
|
|||||||
// Handle methods first.
|
// Handle methods first.
|
||||||
if (auto overriddenFunc = dyn_cast<AbstractFunctionDecl>(overridden)) {
|
if (auto overriddenFunc = dyn_cast<AbstractFunctionDecl>(overridden)) {
|
||||||
// Determine the selector of the overridden method.
|
// Determine the selector of the overridden method.
|
||||||
ObjCSelector overriddenSelector = overriddenFunc->getObjCSelector(&tc);
|
ObjCSelector overriddenSelector = overriddenFunc->getObjCSelector();
|
||||||
|
|
||||||
// Dig out the @objc attribute on the method, if it exists.
|
// Dig out the @objc attribute on the method, if it exists.
|
||||||
auto attr = decl->getAttrs().getAttribute<ObjCAttr>();
|
auto attr = decl->getAttrs().getAttribute<ObjCAttr>();
|
||||||
@@ -2867,7 +2867,7 @@ void swift::markAsObjC(TypeChecker &TC, ValueDecl *D,
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto sel = method->getObjCSelector(&TC);
|
auto sel = method->getObjCSelector();
|
||||||
if (auto diagID = isForbiddenSelector(sel)) {
|
if (auto diagID = isForbiddenSelector(sel)) {
|
||||||
auto diagInfo = getObjCMethodDiagInfo(method);
|
auto diagInfo = getObjCMethodDiagInfo(method);
|
||||||
TC.diagnose(method, *diagID,
|
TC.diagnose(method, *diagID,
|
||||||
@@ -6066,14 +6066,13 @@ public:
|
|||||||
bool objCMatch = false;
|
bool objCMatch = false;
|
||||||
if (parentDecl->isObjC() && decl->isObjC()) {
|
if (parentDecl->isObjC() && decl->isObjC()) {
|
||||||
if (method) {
|
if (method) {
|
||||||
if (method->getObjCSelector(&TC)
|
if (method->getObjCSelector() == parentMethod->getObjCSelector())
|
||||||
== parentMethod->getObjCSelector(&TC))
|
|
||||||
objCMatch = true;
|
objCMatch = true;
|
||||||
} else if (auto *parentSubscript =
|
} else if (auto *parentSubscript =
|
||||||
dyn_cast<SubscriptDecl>(parentStorage)) {
|
dyn_cast<SubscriptDecl>(parentStorage)) {
|
||||||
// If the subscript kinds don't match, it's not an override.
|
// If the subscript kinds don't match, it's not an override.
|
||||||
if (subscript->getObjCSubscriptKind(&TC)
|
if (subscript->getObjCSubscriptKind()
|
||||||
== parentSubscript->getObjCSubscriptKind(&TC))
|
== parentSubscript->getObjCSubscriptKind())
|
||||||
objCMatch = true;
|
objCMatch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6170,11 +6169,11 @@ public:
|
|||||||
if (objCMatch) {
|
if (objCMatch) {
|
||||||
if (method) {
|
if (method) {
|
||||||
TC.diagnose(decl, diag::override_objc_type_mismatch_method,
|
TC.diagnose(decl, diag::override_objc_type_mismatch_method,
|
||||||
method->getObjCSelector(&TC), declTy);
|
method->getObjCSelector(), declTy);
|
||||||
} else {
|
} else {
|
||||||
TC.diagnose(decl, diag::override_objc_type_mismatch_subscript,
|
TC.diagnose(decl, diag::override_objc_type_mismatch_subscript,
|
||||||
static_cast<unsigned>(
|
static_cast<unsigned>(
|
||||||
subscript->getObjCSubscriptKind(&TC)),
|
subscript->getObjCSubscriptKind()),
|
||||||
declTy);
|
declTy);
|
||||||
}
|
}
|
||||||
TC.diagnose(parentDecl, diag::overridden_here_with_type,
|
TC.diagnose(parentDecl, diag::overridden_here_with_type,
|
||||||
|
|||||||
@@ -3835,7 +3835,7 @@ bool TypeChecker::isRepresentableInObjC(const SubscriptDecl *SD,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Make sure we know how to map the selector appropriately.
|
// Make sure we know how to map the selector appropriately.
|
||||||
if (Result && SD->getObjCSubscriptKind(this) == ObjCSubscriptKind::None) {
|
if (Result && SD->getObjCSubscriptKind() == ObjCSubscriptKind::None) {
|
||||||
SourceRange IndexRange = SD->getIndices()->getSourceRange();
|
SourceRange IndexRange = SD->getIndices()->getSourceRange();
|
||||||
diagnose(SD->getLoc(), diag::objc_invalid_subscript_key_type,
|
diagnose(SD->getLoc(), diag::objc_invalid_subscript_key_type,
|
||||||
getObjCDiagnosticAttrKind(Reason), IndicesType)
|
getObjCDiagnosticAttrKind(Reason), IndicesType)
|
||||||
|
|||||||
Reference in New Issue
Block a user