Skip to content

Commit b3e7a23

Browse files
committed
Fix @objc use in module interfaces for objcImpl
objcImpl extensions with final public members need to be printed into module interfaces, but with the @implementation attribute suppressed. That worked fine…but when we switched to the new syntax, we should also have suppressed the @objc attribute, and we mistakenly did not. Correct this oversight. Fixes rdar://129178360.
1 parent 4fc0f3a commit b3e7a23

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,14 @@ void PrintAST::printAttributes(const Decl *D) {
13261326
}
13271327
}
13281328

1329+
// If we are suppressing @implementation, also suppress @objc on extensions.
1330+
if (auto ED = dyn_cast<ExtensionDecl>(D)) {
1331+
if (ED->isObjCImplementation() &&
1332+
Options.excludeAttrKind(DeclAttrKind::ObjCImplementation)) {
1333+
Options.ExcludeAttrList.push_back(DeclAttrKind::ObjC);
1334+
}
1335+
}
1336+
13291337
// We will handle ownership specifiers separately.
13301338
if (isa<FuncDecl>(D)) {
13311339
Options.ExcludeAttrList.push_back(DeclAttrKind::Mutating);

test/ModuleInterface/objc_implementation.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import Foundation
1616

1717
// We should never see @_objcImplementation in the header
1818
// NEGATIVE-NOT: @_objcImplementation
19+
// NEGATIVE-NOT: @implementation
20+
21+
// @objc should be omitted on extensions
22+
// NEGATIVE-NOT: @objc{{.*}} extension
1923

2024
//
2125
// @_objcImplementation class

0 commit comments

Comments
 (0)