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
// expected-opt-in-note @-2 2 {{enum 'HiddenEnum' is not '@usableFromInline' or public}}
108
+
case A
109
+
// expected-opt-in-note @-1 {{enum case 'A' is not '@usableFromInline' or public}}
110
+
case B
111
+
}
112
+
#else
113
+
privateenumHiddenEnum{
114
+
// expected-not-opt-in-note @-1 2 {{enum 'HiddenEnum' is not '@usableFromInline' or public}}
115
+
case A
116
+
// expected-not-opt-in-note @-1 {{enum case 'A' is not '@usableFromInline' or public}}
117
+
case B
118
+
}
119
+
#endif
120
+
100
121
/// Function use sites
101
122
102
123
@inlinable
@@ -114,6 +135,9 @@ public func explicitlyInlinable() {
114
135
let _:ExposedEnumPrivate=ExposedEnumPrivate.A
115
136
// expected-error @-1 2 {{enum 'ExposedEnumPrivate' is private and cannot be referenced from an '@inlinable' function}}
116
137
// expected-error @-2 {{enum case 'A' is private and cannot be referenced from an '@inlinable' function}}
138
+
let _:HiddenEnum=HiddenEnum.A
139
+
// expected-error @-1 2 {{enum 'HiddenEnum' is private and cannot be referenced from an '@inlinable' function}}
140
+
// expected-error @-2 {{enum case 'A' is private and cannot be referenced from an '@inlinable' function}}
117
141
}
118
142
119
143
publicfunc implicitlyInlinablePublic(){
@@ -124,6 +148,8 @@ public func implicitlyInlinablePublic() {
124
148
125
149
let _:ExposedEnumPublic=ExposedEnumPublic.A
126
150
let _:ExposedEnumPrivate=ExposedEnumPrivate.A
151
+
let _:HiddenEnum=HiddenEnum.A
152
+
// expected-embedded-opt-in-error @-1 2 {{enum 'HiddenEnum' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenEnum' is marked '@_implementationOnly'}}
// expected-embedded-opt-in-error @-1 2 {{enum 'HiddenEnum' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenEnum' is marked '@_implementationOnly'}}
137
165
}
138
166
139
167
@_neverEmitIntoClient
@@ -143,6 +171,7 @@ public func explicitNonInliable() {
// expected-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
160
191
161
192
publicvarpublicField:StructFromDirect
162
193
// expected-error @-1 {{cannot use struct 'StructFromDirect' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'directs' has been imported as implementation-only}}
@@ -171,11 +202,17 @@ public struct ExposedLayoutPublicUser {
171
202
privatevarc:HiddenLayout
172
203
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
173
204
205
+
privatevard:ExposedEnumPublic
206
+
privatevare:ExposedEnumPrivate
207
+
privatevarf:HiddenEnum
208
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
209
+
174
210
privatefunc privateFunc(h:HiddenLayout){}
175
211
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
179
216
180
217
privatevarprivateField:StructFromDirect
181
218
// expected-opt-in-error @-1 {{cannot use struct 'StructFromDirect' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'directs' has been imported as implementation-only}}
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
188
225
226
+
privatevard:ExposedEnumPublic
227
+
privatevare:ExposedEnumPrivate
228
+
privatevarf:HiddenEnum
229
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
230
+
189
231
privatefunc privateFunc(h:HiddenLayout){}
190
232
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
194
237
195
238
privatevarprivateField:StructFromDirect
196
239
// expected-opt-in-error @-1 {{cannot use struct 'StructFromDirect' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'directs' has been imported as implementation-only}}
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenLayout' is marked '@_implementationOnly'}}
203
246
247
+
privatevard:ExposedEnumPublic
248
+
privatevare:ExposedEnumPrivate
249
+
privatevarf:HiddenEnum
250
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
251
+
204
252
privatefunc privateFunc(h:HiddenLayout){}
205
253
// expected-embedded-opt-in-error @-1 {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
@_implementationOnly // expected-opt-in-error {{'@_implementationOnly' may not be used on public declarations}}
223
274
publicstructPublicHiddenStruct{}
275
+
276
+
277
+
#endif
278
+
279
+
/// Enums use sites
280
+
281
+
publicenumPublicEnumUser:ProtocolFromDirect{
282
+
// expected-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
283
+
case a(StructFromDirect) // expected-error {{cannot use struct 'StructFromDirect' here; 'directs' has been imported as implementation-only}}
284
+
case b(HiddenLayout) // expected-error {{enum case in a public enum uses a private type}}
285
+
// expected-opt-in-error @-1 {{cannot use struct 'HiddenLayout' here; 'HiddenLayout' is marked '@_implementationOnly'}}
286
+
case c(ExposedLayoutInternal) // expected-error {{enum case in a public enum uses an internal type}}
287
+
case d(ExposedLayoutPrivate) // expected-error {{enum case in a public enum uses a private type}}
288
+
case e(ExposedLayoutPublic)
289
+
}
290
+
291
+
internalenumInternalEnumUser:ProtocolFromDirect{
292
+
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
293
+
case a(StructFromDirect) // expected-opt-in-error {{cannot use struct 'StructFromDirect' here; 'directs' has been imported as implementation-only}}
294
+
case b(HiddenLayout) // expected-opt-in-error {{cannot use struct 'HiddenLayout' here; 'HiddenLayout' is marked '@_implementationOnly'}}
295
+
// expected-error @-1 {{enum case in an internal enum uses a private type}}
296
+
case c(ExposedLayoutInternal)
297
+
case d(ExposedLayoutPrivate) // expected-error {{enum case in an internal enum uses a private type}}
298
+
case e(ExposedLayoutPublic)
299
+
}
300
+
301
+
privateenumPrivateEnumUser:ProtocolFromDirect{
302
+
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
303
+
case a(StructFromDirect) // expected-opt-in-error {{cannot use struct 'StructFromDirect' here; 'directs' has been imported as implementation-only}}
304
+
case b(HiddenLayout) // expected-opt-in-error {{cannot use struct 'HiddenLayout' here; 'HiddenLayout' is marked '@_implementationOnly'}}
305
+
case c(ExposedLayoutInternal)
306
+
case d(ExposedLayoutPrivate)
307
+
case e(ExposedLayoutPublic)
308
+
}
309
+
310
+
internalenumInternalEnumWithRawType:RawTypeFromDirect{ // expected-opt-in-error {{cannot use struct 'RawTypeFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
// expected-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
340
+
229
341
publicinit(){fatalError()}
230
342
231
343
publicvarpublicField:StructFromDirect
@@ -241,12 +353,16 @@ public class PublicClass {
241
353
242
354
privatevard:ExposedEnumPublic
243
355
privatevare:ExposedEnumPrivate
356
+
privatevarf:HiddenEnum
357
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
244
358
245
359
@_neverEmitIntoClient
246
360
privatefunc privateFunc(h:HiddenLayout){}
247
361
}
248
362
249
-
internalclassInternalClass{
363
+
internalclassInternalClass:ProtocolFromDirect{
364
+
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
365
+
250
366
publicinit(){fatalError()}
251
367
252
368
publicvarpublicField:StructFromDirect
@@ -262,11 +378,15 @@ internal class InternalClass {
262
378
263
379
privatevard:ExposedEnumPublic
264
380
privatevare:ExposedEnumPrivate
381
+
privatevarf:HiddenEnum
382
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
265
383
266
384
privatefunc privateFunc(h:HiddenLayout){} // expected-embedded-opt-in-error {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
267
385
}
268
386
269
-
privateclassPrivateClass{
387
+
privateclassPrivateClass:ProtocolFromDirect{
388
+
// expected-opt-in-error @-1 {{cannot use protocol 'ProtocolFromDirect' in a public or '@usableFromInline' conformance; 'directs' has been imported as implementation-only}}
389
+
270
390
publicinit(){fatalError()}
271
391
272
392
publicvarpublicField:StructFromDirect
@@ -282,13 +402,15 @@ private class PrivateClass {
282
402
283
403
privatevard:ExposedEnumPublic
284
404
privatevare:ExposedEnumPrivate
405
+
privatevarf:HiddenEnum
406
+
// expected-opt-in-error @-1 {{cannot use enum 'HiddenEnum' in a property declaration marked public or in a '@frozen' or '@usableFromInline' context; 'HiddenEnum' is marked '@_implementationOnly'}}
285
407
286
408
privatefunc privateFunc(h:HiddenLayout){} // expected-embedded-opt-in-error {{struct 'HiddenLayout' cannot be used in an embedded function not marked '@_neverEmitIntoClient' because 'HiddenLayout' is marked '@_implementationOnly'}}
287
409
}
288
410
289
411
#if UseImplementationOnly
290
412
@_implementationOnly
291
-
internalclassHiddenClass{
413
+
internalclassHiddenClass:ProtocolFromDirect{
292
414
publicinit(){fatalError()}
293
415
294
416
publicvarpublicField:StructFromDirect
@@ -301,6 +423,7 @@ internal class HiddenClass {
301
423
302
424
privatevard:ExposedEnumPublic
303
425
privatevare:ExposedEnumPrivate
426
+
privatevarf:HiddenEnum
304
427
}
305
428
306
429
@_implementationOnly // expected-opt-in-error {{'@_implementationOnly' may not be used on public declarations}}
0 commit comments