Skip to content

Commit 57c607e

Browse files
committed
[SE-0160] Map Clang's swift_objc_members attribute to @objcMembers.
This finishes the implementation of SE-0160, tracked by SR-4481 / rdar://problem/28497874.
1 parent 97db393 commit 57c607e

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

apinotes/XCTest.apinotes

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Classes:
1818
MethodKind: Instance
1919
SwiftName: 'matching(identifier:)'
2020
- Name: XCTestCase
21+
SwiftObjCMembers: true
2122
Methods:
2223
- Selector: 'waitForExpectationsWithTimeout:handler:'
2324
MethodKind: Instance

lib/ClangImporter/ImportDecl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -6722,6 +6722,14 @@ void ClangImporter::Implementation::importAttributes(
67226722
return;
67236723
}
67246724

6725+
// Map Clang's swift_objc_members attribute to @objcMembers.
6726+
if (ID->hasAttr<clang::SwiftObjCMembersAttr>()) {
6727+
if (!MappedDecl->getAttrs().hasAttribute<ObjCMembersAttr>()) {
6728+
auto attr = new (C) ObjCMembersAttr(/*implicit=*/true);
6729+
MappedDecl->getAttrs().add(attr);
6730+
}
6731+
}
6732+
67256733
// Infer @objcMembers on XCTestCase.
67266734
if (ID->getName() == "XCTestCase") {
67276735
if (!MappedDecl->getAttrs().hasAttribute<ObjCMembersAttr>()) {

test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.apinotes

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Name: APINotesFrameworkTest
22
Classes:
3+
- Name: A
4+
SwiftObjCMembers: true
35
- Name: TestProperties
46
Properties:
57
- Name: accessorsOnly

test/APINotes/basic.swift

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
import APINotesTest
33
import APINotesFrameworkTest
44

5+
extension A {
6+
func implicitlyObjC() { }
7+
}
8+
9+
func testSelectors(a: AnyObject) {
10+
a.implicitlyObjC?() // okay: would complain without SwiftObjCMembers
11+
}
12+
513
func testSwiftName() {
614
moveTo(x: 0, y: 0, z: 0)
715
moveTo(0, 0, 0) // expected-error{{missing argument labels 'x:y:z:' in call}}

0 commit comments

Comments
 (0)