Skip to content

Commit 59fd697

Browse files
authored
Merge pull request #29538 from CodaFi/heavy-industrial-runoff
[NFC] Commit a regression test for rdar://58960414
2 parents a56cd12 + d2ad3dc commit 59fd697

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ typedef struct SomeStruct_s {
1919
@interface MyDerivedClass : MyBaseClass
2020
@property (nonatomic, strong, nullable) Base *derivedMember;
2121
@end
22+
23+
typedef enum {
24+
Caster,
25+
Grantulated,
26+
Confectioners,
27+
Cane,
28+
Demerara,
29+
Turbinado,
30+
} RefinedSugar /*NS_REFINED_FOR_SWIFT*/ __attribute__((swift_private));
31+
32+
@interface Refinery : Base
33+
@property (nonatomic, readonly) RefinedSugar sugar /*NS_REFINED_FOR_SWIFT*/ __attribute__((swift_private));
34+
@end

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414

1515
@interface MyBaseClass () <MyPrivateProtocol>
1616
@end
17+
18+
@interface Refinery ()
19+
@property (nonatomic, readwrite) RefinedSugar sugar;
20+
@end

test/ClangImporter/objc_redeclared_properties_categories.swift

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -typecheck -F %S/Inputs/frameworks %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PUBLIC %s
22

33
// RUN: echo '#import <CategoryOverrides/Private.h>' > %t.h
4-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s --allow-empty
4+
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -F %S/Inputs/frameworks -enable-objc-interop -import-objc-header %t.h %s 2>&1 | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-PRIVATE %s --allow-empty
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
7-
// 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-
// 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
7+
// RUN: not %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+
// RUN: not %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

@@ -54,3 +54,27 @@ func takesABaseClass(_ x: MyBaseClass) {
5454
// CHECK-PRIVATE-NOT: has no member 'derivedMember'
5555
x.derivedMember = Base()
5656
}
57+
58+
// A category declared in a (private) header can introduce overrides of a
59+
// property that has mismatched Swift naming conventions. If we see a
60+
// non-__attribute__((swift_private)) decl, sometimes it comes in too.
61+
62+
extension Refinery {
63+
public enum RefinedSugar {
64+
case caster
65+
case grantulated
66+
case confectioners
67+
case cane
68+
case demerara
69+
case turbinado
70+
}
71+
72+
public var sugar: Refinery.RefinedSugar {
73+
return .caster // RefinedSugar(self.__sugar)
74+
}
75+
}
76+
77+
func takesARefinery(_ x: Refinery) {
78+
// CHECK: cannot assign to property: 'sugar' is a get-only property
79+
x.sugar = .caster
80+
}

0 commit comments

Comments
 (0)