Skip to content

Commit 33ac01d

Browse files
authored
Merge pull request #29257 from CodaFi/scattergories
2 parents 35bfe2a + 5e760a0 commit 33ac01d

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ __attribute__((objc_root_class))
33
- (nonnull instancetype)init;
44
@end
55

6+
typedef struct SomeStruct_s {
7+
int inner;
8+
} SomeStruct;
9+
610
@interface MyColor : Base
711
@property (class, nonatomic, readonly) MyColor *systemRedColor;
812
@end
913

1014
@interface MyBaseClass : Base
1115
// @property (nonatomic, strong, nullable) Base *derivedMember;
16+
@property (nonatomic, assign, readonly) SomeStruct myStructure;
1217
@end
1318

1419
@interface MyDerivedClass : MyBaseClass

test/ClangImporter/Inputs/frameworks/CategoryOverrides.framework/PrivateHeaders/Private.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77
@interface MyColor ()
88
+ (MyColor * _Null_unspecified) systemRedColor;
99
@end
10+
11+
@protocol MyPrivateProtocol
12+
- (SomeStruct) myStructure;
13+
@end
14+
15+
@interface MyBaseClass () <MyPrivateProtocol>
16+
@end

test/ClangImporter/objc_redeclared_properties_categories.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-pch -F %S/Inputs/frameworks -o %t.pch %t.h
77
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
8-
// RUNT: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
8+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck --allow-empty -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s
99

1010
import CategoryOverrides
1111

@@ -19,10 +19,25 @@ import CategoryOverrides
1919
// This configuration appears as an undiagnosed redeclaration of a property and
2020
// function, which is illegal.
2121
func colors() {
22+
// CHECK-PUBLIC: cannot call value of non-function type 'MyColor?'
23+
// CHECK-PRIVATE-NOT: cannot call value of non-function type 'MyColor?'
2224
let _ : MyColor = MyColor.systemRed
2325
let _ : MyColor = MyColor.systemRed()!
2426
}
2527

28+
// Another manifestation of the above for an instance property this time.
29+
func structs(_ base: MyBaseClass, _ derived: MyDerivedClass) {
30+
// CHECK-PUBLIC: cannot call value of non-function type 'SomeStruct'
31+
// CHECK-PRIVATE-NOT: cannot call value of non-function type 'SomeStruct'
32+
let _ : SomeStruct = base.myStructure
33+
let _ : SomeStruct = base.myStructure()
34+
35+
// CHECK-PUBLIC: cannot call value of non-function type 'SomeStruct'
36+
// CHECK-PRIVATE-NOT: cannot call value of non-function type 'SomeStruct'
37+
let _ : SomeStruct = derived.myStructure
38+
let _ : SomeStruct = derived.myStructure()
39+
}
40+
2641
// A category declared in a (private) header can introduce overrides of a property
2742
// that is otherwise not declared in a base class.
2843
//

0 commit comments

Comments
 (0)