File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -1073,8 +1073,15 @@ const AvailableAttr *AvailableAttr::isUnavailable(const Decl *D) {
1073
1073
return attr;
1074
1074
1075
1075
// If D is an extension member, check if the extension is unavailable.
1076
- if (auto ext = dyn_cast<ExtensionDecl>(D->getDeclContext ()))
1077
- return AvailableAttr::isUnavailable (ext);
1076
+ //
1077
+ // Skip decls imported from Clang, they could be associated to the wrong
1078
+ // extension and inherit undesired unavailability. The ClangImporter
1079
+ // associates Objective-C protocol members to the first category where the
1080
+ // protocol is directly or indirectly adopted, no matter its availability
1081
+ // and the availability of other categories. rdar://problem/53956555
1082
+ if (!D->getClangNode ())
1083
+ if (auto ext = dyn_cast<ExtensionDecl>(D->getDeclContext ()))
1084
+ return AvailableAttr::isUnavailable (ext);
1078
1085
1079
1086
return nullptr ;
1080
1087
}
Original file line number Diff line number Diff line change
1
+ #import < Foundation/Foundation.h>
2
+
3
+ @interface SharedInterface
4
+ @end
5
+
6
+ @protocol SharedProtocol <NSObject >
7
+ + (NSInteger )foo ;
8
+ @end
9
+
10
+ // ClangImporter imports the first category as the extension parent of
11
+ // SharedInterface.foo, making foo unavailable on macOS when the extension
12
+ // unavailability is inherited by its members.
13
+ API_UNAVAILABLE (macos)
14
+ @interface SharedInterface (IOSCategory) <SharedProtocol>
15
+ @end
16
+
17
+ API_UNAVAILABLE(ios)
18
+ @interface SharedInterface (MacOSCategory) <SharedProtocol>
19
+ @end
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/availability_platform_categories.h
2
+
3
+ // REQUIRES: OS=macos
4
+
5
+ // Test when a function is associated to an Objective-C category with the
6
+ // wrong unavailability. rdar://problem/53956555
7
+
8
+ print ( SharedInterface . foo ( ) )
You can’t perform that action at this time.
0 commit comments