Skip to content

Commit 3990e17

Browse files
authored
Merge pull request #71938 from beccadax/objcimpl-redundant-conformance-class-ext
Fix class extension visibility bug
2 parents f336ada + f9a1c4d commit 3990e17

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6105,8 +6105,13 @@ ClangCategoryLookupRequest::evaluate(Evaluator &evaluator,
61056105
llvm::TinyPtrVector<Decl *> results;
61066106
results.push_back(const_cast<ClassDecl *>(CD));
61076107

6108+
auto importer =
6109+
static_cast<ClangImporter *>(CD->getASTContext().getClangModuleLoader());
6110+
ClangImporter::Implementation &impl = importer->Impl;
6111+
61086112
for (auto clangExt : clangClass->known_extensions()) {
6109-
results.push_back(importCategory(clangExt));
6113+
if (impl.getClangSema().isVisible(clangExt))
6114+
results.push_back(importCategory(clangExt));
61106115
}
61116116

61126117
return results;

test/ClangImporter/Inputs/frameworks/Module.framework/Headers/Module.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const char *getModuleVersion(void);
88
+alloc;
99
@end
1010

11+
@protocol ModuleProto @end
12+
1113
#define MODULE_H_MACRO 1
1214
#__private_macro MODULE_H_MACRO
1315

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework module Module_Private {
2+
umbrella "PrivateHeaders"
3+
explicit module * { export * }
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Module/Module.h>
2+
3+
@interface Module () <ModuleProto>
4+
@property (readwrite) int extensionProperty;
5+
@end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import <Module/Module.h>

test/ClangImporter/diags_from_module.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Module
3737
// CHECK-PRIMARY: diags_from_module.swift:[[@LINE-4]]:8: error: could not build Objective-C module 'Module'
3838

3939
// CHECK-WARN: Sub2.h:7:2: warning: here is some warning about something
40-
// CHECK-WARN: Module.h:20:1: warning: umbrella header for module 'Module' does not include header 'NotInModule.h'
40+
// CHECK-WARN: Module.h:22:1: warning: umbrella header for module 'Module' does not include header 'NotInModule.h'
4141
// FIXME: show [-Wincomplete-umbrella]
4242

4343
// CHECK-NO-WARN-NOT: warning about something
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-typecheck-verify-swift -F %S/Inputs/frameworks -module-cache-path %t/mcp1
3+
4+
// REQUIRES: objc_interop
5+
6+
import Module
7+
import Module_Private.Sub4
8+
9+
@_objcImplementation extension Module {
10+
// expected-error@-1 {{'@_objcImplementation' cannot be used to implement root class 'Module'}}
11+
// expected-warning@-2 {{extension for main class interface should provide implementation for class method 'version()'}}
12+
// expected-warning@-3 {{extension for main class interface should provide implementation for class method 'alloc()'}}
13+
}
14+
15+
extension Module: @retroactive ModuleProto {} // no-error

0 commit comments

Comments
 (0)