You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Sema] Add test for references to restricted imports from frozen structs
Exporting types imported as non-public in @Frozen strucs is reported by
pre-existing mechanics using the access-levels system. This simply adds
a test to prevent regressions.
@@ -52,6 +53,8 @@ public struct InternalImportType {
52
53
}
53
54
publicfunc InternalFunc(){}
54
55
56
+
@frozenpublicstructInternalImportFrozenType{}
57
+
55
58
//--- FileprivateLib.swift
56
59
publicprotocolFileprivateImportProto{
57
60
associatedtypeT
@@ -74,20 +77,21 @@ public struct PrivateImportType {
74
77
publicimport PublicLib
75
78
76
79
packageimport PackageLib
77
-
// expected-note@-1 2 {{struct 'PackageImportType' imported as 'package' from 'PackageLib' here}}
80
+
// expected-note@-1 4 {{struct 'PackageImportType' imported as 'package' from 'PackageLib' here}}
78
81
79
82
internalimport InternalLib
80
-
// expected-note@-1 6 {{struct 'InternalImportType' imported as 'internal' from 'InternalLib' here}}
83
+
// expected-note@-1 9 {{struct 'InternalImportType' imported as 'internal' from 'InternalLib' here}}
81
84
// expected-note@-2 4 {{protocol 'InternalImportProto' imported as 'internal' from 'InternalLib' here}}
82
85
// expected-note@-3 2 {{global function 'InternalFunc()' imported as 'internal' from 'InternalLib' here}}
86
+
// expected-note@-4 2 {{struct 'InternalImportFrozenType' imported as 'internal' from 'InternalLib' here}}
83
87
84
88
fileprivateimport FileprivateLib
85
89
// expected-note@-1 2 {{generic struct 'FileprivateImportWrapper' imported as 'fileprivate' from 'FileprivateLib' here}}
86
90
// expected-note@-2 2 {{initializer 'init(wrappedValue:)' imported as 'fileprivate' from 'FileprivateLib' here}}
87
91
// expected-note@-3 2 {{protocol 'FileprivateImportProto' imported as 'fileprivate' from 'FileprivateLib' here}}
88
92
89
93
privateimport PrivateLib
90
-
// expected-note@-1 4 {{struct 'PrivateImportType' imported as 'private' from 'PrivateLib' here}}
94
+
// expected-note@-1 10 {{struct 'PrivateImportType' imported as 'private' from 'PrivateLib' here}}
91
95
// expected-note@-2 2 {{initializer 'init()' imported as 'private' from 'PrivateLib' here}}
92
96
93
97
publicstructGenericType<T, U>{}
@@ -171,3 +175,87 @@ public struct GenericType<T, U> {}
171
175
let _:GenericType<InternalImportType,PrivateImportType> // expected-error {{struct 'InternalImportType' is internal and cannot be referenced from an '@_alwaysEmitIntoClient' function}}
172
176
// expected-error @-1 {{struct 'PrivateImportType' is private and cannot be referenced from an '@_alwaysEmitIntoClient' function}}
173
177
}
178
+
179
+
@frozenpublicstructBadFields1{
180
+
privatevarfield:PrivateImportType // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
181
+
}
182
+
183
+
@_fixed_layoutpublicstructFixedBadFields1{
184
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
185
+
privatevarfield:PrivateImportType // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
186
+
}
187
+
188
+
@frozenpublicstructBadFields2{
189
+
privatevarfield:PrivateImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
190
+
}
191
+
192
+
@_fixed_layoutpublicstructFixedBadFields2{
193
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
194
+
privatevarfield:PrivateImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
195
+
}
196
+
197
+
@frozenpublicstructBadFields3{
198
+
internalvarfield:PackageImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
199
+
}
200
+
201
+
@_fixed_layoutpublicstructFixedBadFields3{
202
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
203
+
internalvarfield:PackageImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
204
+
}
205
+
206
+
@frozen@usableFromInlinestructBadFields4{
207
+
internalvarfield:InternalImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
212
+
internalvarfield:InternalImportType? // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
213
+
}
214
+
215
+
@frozenpublicstructBadFields5{
216
+
privatevarfield:PrivateImportType?{ // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
217
+
didSet {}
218
+
}
219
+
}
220
+
221
+
@_fixed_layoutpublicstructFixedBadFields5{
222
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
223
+
privatevarfield:PrivateImportType?{ // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
224
+
didSet {}
225
+
}
226
+
}
227
+
228
+
@frozenpublicstructBadFields6{
229
+
privatevarfield:InternalImportFrozenType?{ // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
230
+
didSet {}
231
+
}
232
+
}
233
+
234
+
@_fixed_layoutpublicstructFixedBadFields6{
235
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
236
+
privatevarfield:InternalImportFrozenType?{ // expected-error {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
237
+
didSet {}
238
+
}
239
+
}
240
+
241
+
// expected-error@+1 {{the result of a '@usableFromInline' function must be '@usableFromInline' or public}}
privatevarfield=notReallyUsableFromInline() // expected-error {{type referenced from a stored property with inferred type 'InternalImportType?' in a '@frozen' struct must be '@usableFromInline' or public}}
245
+
}
246
+
247
+
@_fixed_layoutpublicstructFrozenBadFields7{
248
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
249
+
privatevarfield=notReallyUsableFromInline() // expected-error {{type referenced from a stored property with inferred type 'InternalImportType?' in a '@frozen' struct must be '@usableFromInline' or public}}
250
+
}
251
+
252
+
@frozenpublicstructOKFields{
253
+
internalstaticvarstaticProp:InternalImportType?
254
+
privatevarcomputed:PrivateImportType?{returnnil}
255
+
}
256
+
257
+
@_fixed_layoutpublicstructFixedOKFields{
258
+
// expected-warning@-1 {{'@frozen' attribute is now used for fixed-layout structs}}
0 commit comments