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.
This commit is contained in:
Becca Royal-Gordon
2024-06-04 17:47:05 -07:00
parent 4fc0f3ab61
commit b3e7a23e70
2 changed files with 12 additions and 0 deletions

View File

@@ -1326,6 +1326,14 @@ void PrintAST::printAttributes(const Decl *D) {
}
}
// If we are suppressing @implementation, also suppress @objc on extensions.
if (auto ED = dyn_cast<ExtensionDecl>(D)) {
if (ED->isObjCImplementation() &&
Options.excludeAttrKind(DeclAttrKind::ObjCImplementation)) {
Options.ExcludeAttrList.push_back(DeclAttrKind::ObjC);
}
}
// We will handle ownership specifiers separately.
if (isa<FuncDecl>(D)) {
Options.ExcludeAttrList.push_back(DeclAttrKind::Mutating);

View File

@@ -16,6 +16,10 @@ import Foundation
// We should never see @_objcImplementation in the header
// NEGATIVE-NOT: @_objcImplementation
// NEGATIVE-NOT: @implementation
// @objc should be omitted on extensions
// NEGATIVE-NOT: @objc{{.*}} extension
//
// @_objcImplementation class