mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Your monthly dose of minor @objc fixes
- Disallow @objc on members of non-@objc protocols (the real reason for this patch) - Add a separate diagnostic for @objc appearing on members in non-class, non-protocol types. - Clean up the code that enforces that @objc can only be applied to @objc-rooted classes. The diagnostic would be incorrectly emitted for @objc subclasses of generic classes. Fixes <rdar://problem/17273524>. Swift SVN r31303
This commit is contained in:
@@ -2259,7 +2259,7 @@ ObjCClassKind ClassDecl::checkObjCAncestry() const {
|
||||
bool genericAncestry = false, isObjC = false;
|
||||
const ClassDecl *CD = this;
|
||||
|
||||
while (CD) {
|
||||
for (;;) {
|
||||
// If we hit circularity, we will diagnose at some point in typeCheckDecl().
|
||||
// However we have to explicitly guard against that here because we get
|
||||
// called as part of validateDecl().
|
||||
@@ -2272,17 +2272,18 @@ ObjCClassKind ClassDecl::checkObjCAncestry() const {
|
||||
if (CD->isObjC())
|
||||
isObjC = true;
|
||||
|
||||
const ClassDecl *superclassDecl = nullptr;
|
||||
if (CD->hasSuperclass())
|
||||
superclassDecl = CD->getSuperclass()->getClassOrBoundGenericClass();
|
||||
CD = superclassDecl;
|
||||
if (!CD->hasSuperclass())
|
||||
break;
|
||||
CD = CD->getSuperclass()->getClassOrBoundGenericClass();
|
||||
}
|
||||
|
||||
|
||||
if (!isObjC)
|
||||
return ObjCClassKind::NonObjC;
|
||||
if (genericAncestry)
|
||||
return ObjCClassKind::ObjCMembers;
|
||||
if (CD == this || !CD->isObjC())
|
||||
return ObjCClassKind::ObjCWithSwiftRoot;
|
||||
|
||||
return ObjCClassKind::ObjC;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user