- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathaccess-level-import-exportability.swift
917 lines (831 loc) · 46.4 KB
/
access-level-import-exportability.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
// RUN: %empty-directory(%t)
// RUN: split-file --leading-lines %s %t
/// Build the libraries.
// RUN: %target-swift-frontend -emit-module %t/PublicLib.swift -o %t \
// RUN: -enable-library-evolution
// RUN: %target-swift-frontend -emit-module %t/PackageLib.swift -o %t \
// RUN: -enable-library-evolution
// RUN: %target-swift-frontend -emit-module %t/InternalLib.swift -o %t \
// RUN: -enable-library-evolution
// RUN: %target-swift-frontend -emit-module %t/FileprivateLib.swift -o %t \
// RUN: -enable-library-evolution
// RUN: %target-swift-frontend -emit-module %t/PrivateLib.swift -o %t \
// RUN: -enable-library-evolution
/// Check diagnostics.
// RUN: %target-swift-frontend -typecheck %t/MinimalClient.swift -I %t \
// RUN: -package-name TestPackage -swift-version 5 -verify
// RUN: %target-swift-frontend -typecheck %t/CompletenessClient.swift -I %t \
// RUN: -package-name TestPackage -swift-version 5 -verify
/// Check diagnostics with library-evolution.
// RUN: %target-swift-frontend -typecheck %t/MinimalClient.swift -I %t \
// RUN: -package-name TestPackage -swift-version 5 \
// RUN: -enable-library-evolution -verify
// RUN: %target-swift-frontend -typecheck %t/CompletenessClient.swift -I %t \
// RUN: -package-name TestPackage -swift-version 5 \
// RUN: -enable-library-evolution -verify
//--- PublicLib.swift
publicprotocolPublicImportProto{
associatedtypeT
}
publicstructPublicImportType{
publicinit(){}
}
openclassPublicImportClass{}
@propertyWrapper
publicstructPublicLibWrapper<T>{
publicvarwrappedValue:T
publicinit(wrappedValue:T){
self.wrappedValue = wrappedValue
}
}
//--- PackageLib.swift
publicprotocolPackageImportProto{
associatedtypeT
}
publicstructPackageImportType{
publicinit(){}
}
openclassPackageImportClass{}
@propertyWrapper
publicstructPackageLibWrapper<T>{
publicvarwrappedValue:T
publicinit(wrappedValue:T){
self.wrappedValue = wrappedValue
}
}
//--- InternalLib.swift
publicprotocolInternalImportProto{
associatedtypeT
}
publicstructInternalImportType{
publicinit(){}
}
openclassInternalImportClass{}
publicfunc InternalFunc(){}
@propertyWrapper
publicstructInternalLibWrapper<T>{
publicvarwrappedValue:T
publicinit(wrappedValue:T){
self.wrappedValue = wrappedValue
}
}
//--- FileprivateLib.swift
publicprotocolFileprivateImportProto{
associatedtypeT
}
publicstructFileprivateImportType{
publicinit(){}
}
openclassFileprivateImportClass{}
@propertyWrapper
publicstructFileprivateLibWrapper<T>{
publicvarwrappedValue:T
publicinit(wrappedValue:T){
self.wrappedValue = wrappedValue
}
}
//--- PrivateLib.swift
publicprotocolPrivateImportProto{
associatedtypeT
}
publicstructPrivateImportType{
publicinit(){}
}
openclassPrivateImportClass{}
@propertyWrapper
publicstructPrivateLibWrapper<T>{
publicvarwrappedValue:T
publicinit(wrappedValue:T){
self.wrappedValue = wrappedValue
}
}
/// Short test mostly to count the notes.
//--- MinimalClient.swift
publicimport PublicLib // expected-warning {{public import of 'PublicLib' was not used in public declarations or inlinable code}}
packageimport PackageLib // expected-warning {{package import of 'PackageLib' was not used in package declarations}}
internalimport InternalLib // expected-note {{struct 'InternalImportType' imported as 'internal' from 'InternalLib' here}}
fileprivateimport FileprivateLib // expected-note {{class 'FileprivateImportClass' imported as 'fileprivate' from 'FileprivateLib' here}}
privateimport PrivateLib
publicfunc PublicFuncUsesInternal(_:InternalImportType){ // expected-error {{function cannot be declared public because its parameter uses an internal type}}
// expected-note @-1 {{struct 'InternalImportType' is imported by this file as 'internal' from 'InternalLib'}}
var _:InternalImportType
}
publicclassPublicSubclassFileprivate:FileprivateImportClass{} // expected-error {{class cannot be declared public because its superclass is fileprivate}}
// expected-note @-1 {{class 'FileprivateImportClass' is imported by this file as 'fileprivate' from 'FileprivateLib'}}
/// More complete test.
//--- CompletenessClient.swift
publicimport PublicLib
packageimport PackageLib // expected-note * {{module 'PackageLib' imported as 'package' here}}
// expected-note@-1 * {{imported as 'package' from 'PackageLib' here}}
internalimport InternalLib // expected-note * {{module 'InternalLib' imported as 'internal' here}}
// expected-note@-1 * {{imported as 'internal' from 'InternalLib' here}}
fileprivateimport FileprivateLib // expected-note * {{module 'FileprivateLib' imported as 'fileprivate' here}}
// expected-note@-1 * {{imported as 'fileprivate' from 'FileprivateLib' here}}
privateimport PrivateLib // expected-note * {{module 'PrivateLib' imported as 'private' here}}
// expected-note@-1 * {{imported as 'private' from 'PrivateLib' here}}
// Public use sites
publicfunc PublicFuncUsesPublic(_:PublicImportType){
var _:PublicImportType
}
publicfunc PublicFuncUsesPackage(_:PackageImportType){ // expected-error {{function cannot be declared public because its parameter uses a package type}}
// expected-note @-1 {{is imported by this file as}}
var _:PackageImportType
}
publicfunc PublicFuncUsesInternal(_:InternalImportType){ // expected-error {{function cannot be declared public because its parameter uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
var _:InternalImportType
}
publicfunc PublicFuncUsesFileprivate(_:FileprivateImportType){ // expected-error {{function cannot be declared public because its parameter uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
var _:FileprivateImportType
}
publicfunc PublicFuncUsesPrivate(_:PrivateImportType){ // expected-error {{function cannot be declared public because its parameter uses a private type}}
// expected-note @-1 {{is imported by this file as}}
var _:PrivateImportType
}
// Package use sites
packagefunc PackageFuncUsesPublic(_:PublicImportType){
var _:PublicImportType
}
packagefunc PackageFuncUsesPackage(_:PackageImportType){
var _:PackageImportType
}
packagefunc PackageFuncUsesInternal(_:InternalImportType){ // expected-error {{function cannot be declared package because its parameter uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
var _:InternalImportType
}
packagefunc PackageFuncUsesFileprivate(_:FileprivateImportType){ // expected-error {{function cannot be declared package because its parameter uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
var _:FileprivateImportType
}
packagefunc PackageFuncUsesPrivate(_:PrivateImportType){ // expected-error {{function cannot be declared package because its parameter uses a private type}}
// expected-note @-1 {{is imported by this file as}}
var _:PrivateImportType
}
// Internal use sites
internalfunc InternalFuncUsesPublic(_:PublicImportType){
var _:PublicImportType
}
internalfunc InternalFuncUsesPackage(_:PackageImportType){
var _:PackageImportType
}
internalfunc InternalFuncUsesInternal(_:InternalImportType){
var _:InternalImportType
}
internalfunc InternalFuncUsesFileprivate(_:FileprivateImportType){ // expected-error {{function cannot be declared internal because its parameter uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
var _:FileprivateImportType
}
internalfunc InternalFuncUsesPrivate(_:PrivateImportType){ // expected-error {{function cannot be declared internal because its parameter uses a private type}}
// expected-note @-1 {{is imported by this file as}}
var _:PrivateImportType
}
// Fileprivate use sites
fileprivatefunc FileprivateFuncUsesPublic(_:PublicImportType){
var _:PublicImportType
}
fileprivatefunc FileprivateFuncUsesPackage(_:PackageImportType){
var _:PackageImportType
}
fileprivatefunc FileprivateFuncUsesInternal(_:InternalImportType){
var _:InternalImportType
}
fileprivatefunc FileprivateFuncUsesFileprivate(_:FileprivateImportType){
var _:FileprivateImportType
}
fileprivatefunc FileprivateFuncUsesPrivate(_:PrivateImportType){
var _:PrivateImportType
}
// Private use sites
privatefunc PrivateFuncUsesPublic(_:PublicImportType){
var _:PublicImportType
}
privatefunc PrivateFuncUsesPackage(_:PackageImportType){
var _:PackageImportType
}
privatefunc PrivateFuncUsesInternal(_:InternalImportType){
var _:InternalImportType
}
privatefunc PrivateFuncUsesFileprivate(_:FileprivateImportType){
var _:FileprivateImportType
}
privatefunc PrivateFuncUsesPrivate(_:PrivateImportType){
var _:PrivateImportType
}
// Public returns
publicfunc PublicFuncReturnUsesPublic()->PublicImportType{
fatalError()
}
publicfunc PublicFuncReturnUsesPackage()->PackageImportType{ // expected-error {{function cannot be declared public because its result uses a package type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
publicfunc PublicFuncReturnUsesInternal()->InternalImportType{ // expected-error {{function cannot be declared public because its result uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
publicfunc PublicFuncReturnUsesFileprivate()->FileprivateImportType{ // expected-error {{function cannot be declared public because its result uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
publicfunc PublicFuncReturnUsesPrivate()->PrivateImportType{ // expected-error {{function cannot be declared public because its result uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
// Package returns
packagefunc PackageFuncReturnUsesPublic()->PublicImportType{
fatalError()
}
packagefunc PackageFuncReturnUsesPackage()->PackageImportType{
fatalError()
}
packagefunc PackageFuncReturnUsesInternal()->InternalImportType{ // expected-error {{function cannot be declared package because its result uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
packagefunc PackageFuncReturnUsesFileprivate()->FileprivateImportType{ // expected-error {{function cannot be declared package because its result uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
packagefunc PackageFuncReturnUsesPrivate()->PrivateImportType{ // expected-error {{function cannot be declared package because its result uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
// Internal returns
internalfunc InternalFuncReturnUsesPublic()->PublicImportType{
fatalError()
}
internalfunc InternalFuncReturnUsesPackage()->PackageImportType{
fatalError()
}
internalfunc InternalFuncReturnUsesInternal()->InternalImportType{
fatalError()
}
internalfunc InternalFuncReturnUsesFileprivate()->FileprivateImportType{ // expected-error {{function cannot be declared internal because its result uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
internalfunc InternalFuncReturnUsesPrivate()->PrivateImportType{ // expected-error {{function cannot be declared internal because its result uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
// Fileprivate returns
fileprivatefunc FileprivateFuncReturnUsesPublic()->PublicImportType{
fatalError()
}
fileprivatefunc FileprivateFuncReturnUsesPackage()->PackageImportType{
fatalError()
}
fileprivatefunc FileprivateFuncReturnUsesInternal()->InternalImportType{
fatalError()
}
fileprivatefunc FileprivateFuncReturnUsesFileprivate()->FileprivateImportType{
fatalError()
}
fileprivatefunc FileprivateFuncReturnUsesPrivate()->PrivateImportType{
fatalError()
}
// Private returns
privatefunc PrivateFuncReturnUsesPublic()->PublicImportType{
fatalError()
}
privatefunc PrivateFuncReturnUsesPackage()->PackageImportType{
fatalError()
}
privatefunc PrivateFuncReturnUsesInternal()->InternalImportType{
fatalError()
}
privatefunc PrivateFuncReturnUsesFileprivate()->FileprivateImportType{
fatalError()
}
privatefunc PrivateFuncReturnUsesPrivate()->PrivateImportType{
fatalError()
}
// Public subscripts
publicstructPublicSubscriptUsesPublic{
public subscript(index:PublicImportType)->PublicImportType{
fatalError()
}
}
publicstructPublicSubscriptUsesPackage{
public subscript(index:PackageImportType)->PackageImportType{ // expected-error {{subscript cannot be declared public because its element type uses a package type}}
// expected-note @-1 {{is imported by this file as}}
// This error should be on the `index` like the other ones.
fatalError()
}
}
publicstructPublicSubscriptUsesInternal{
public subscript(index:InternalImportType)->InternalImportType{ // expected-error {{subscript cannot be declared public because its index uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
publicstructPublicSubscriptUsesFileprivate{
public subscript(index:FileprivateImportType)->FileprivateImportType{ // expected-error {{subscript cannot be declared public because its index uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
publicstructPublicSubscriptUsesPrivate{
public subscript(index:PrivateImportType)->PrivateImportType{ // expected-error {{subscript cannot be declared public because its index uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
// Package subscripts
packagestructPackageSubscriptUsesPublic{
package subscript(index:PublicImportType)->PublicImportType{
fatalError()
}
}
packagestructPackageSubscriptUsesPackage{
package subscript(index:PackageImportType)->PackageImportType{
fatalError()
}
}
packagestructPackageSubscriptUsesInternal{
package subscript(index:InternalImportType)->InternalImportType{ // expected-error {{subscript cannot be declared package because its index uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
packagestructPackageSubscriptUsesFileprivate{
package subscript(index:FileprivateImportType)->FileprivateImportType{ // expected-error {{subscript cannot be declared package because its index uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
packagestructPackageSubscriptUsesPrivate{
package subscript(index:PrivateImportType)->PrivateImportType{ // expected-error {{subscript cannot be declared package because its index uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
// Internal subscripts
internalstructInternalSubscriptUsesPublic{
internal subscript(index:PublicImportType)->PublicImportType{
fatalError()
}
}
internalstructInternalSubscriptUsesPackage{
internal subscript(index:PackageImportType)->PackageImportType{
fatalError()
}
}
internalstructInternalSubscriptUsesInternal{
internal subscript(index:InternalImportType)->InternalImportType{
fatalError()
}
}
internalstructInternalSubscriptUsesFileprivate{
internal subscript(index:FileprivateImportType)->FileprivateImportType{ // expected-error {{subscript cannot be declared internal because its index uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
internalstructInternalSubscriptUsesPrivate{
internal subscript(index:PrivateImportType)->PrivateImportType{ // expected-error {{subscript cannot be declared internal because its index uses a private type}}
// expected-note @-1 {{is imported by this file as}}
fatalError()
}
}
// Fileprivate subscripts
fileprivatestructFileprivateSubscriptUsesPublic{
fileprivate subscript(index:PublicImportType)->PublicImportType{
fatalError()
}
}
fileprivatestructFileprivateSubscriptUsesPackage{
fileprivate subscript(index:PackageImportType)->PackageImportType{
fatalError()
}
}
fileprivatestructFileprivateSubscriptUsesInternal{
fileprivate subscript(index:InternalImportType)->InternalImportType{
fatalError()
}
}
fileprivatestructFileprivateSubscriptUsesFileprivate{
fileprivate subscript(index:FileprivateImportType)->FileprivateImportType{
fatalError()
}
}
fileprivatestructFileprivateSubscriptUsesPrivate{
fileprivate subscript(index:PrivateImportType)->PrivateImportType{
fatalError()
}
}
// Private subscripts
privatestructPrivateSubscriptUsesPublic{
private subscript(index:PublicImportType)->PublicImportType{
fatalError()
}
}
privatestructPrivateSubscriptUsesPackage{
private subscript(index:PackageImportType)->PackageImportType{
fatalError()
}
}
privatestructPrivateSubscriptUsesInternal{
private subscript(index:InternalImportType)->InternalImportType{
fatalError()
}
}
privatestructPrivateSubscriptUsesFileprivate{
private subscript(index:FileprivateImportType)->FileprivateImportType{
fatalError()
}
}
privatestructPrivateSubscriptUsesPrivate{
private subscript(index:PrivateImportType)->PrivateImportType{
fatalError()
}
}
publicprotocolPublicProtoUsesPublic:PublicImportProtowhere T ==PublicImportType{}
publicprotocolPublicProtoWherePackage:PublicImportProtowhere T ==PackageImportType{} // expected-error {{public protocol's 'where' clause cannot use a package struct}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoWhereInternal:PublicImportProtowhere T ==InternalImportType{} // expected-error {{public protocol's 'where' clause cannot use an internal struct}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoWhereFileprivate:PublicImportProtowhere T ==FileprivateImportType{} // expected-error {{public protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoWherePrivate:PublicImportProtowhere T ==PrivateImportType{} // expected-error {{public protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoRefinesPublic:PublicImportProto{}
publicprotocolPublicProtoRefinesPackage:PackageImportProto{} // expected-error {{public protocol cannot refine a package protocol}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoRefinesInternal:InternalImportProto{} // expected-error {{public protocol cannot refine an internal protocol}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoRefinesFileprivate:FileprivateImportProto{} // expected-error {{public protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
publicprotocolPublicProtoRefinesPrivate:PrivateImportProto{} // expected-error {{public protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
publicclassPublicSubclassPublic:PublicImportClass{}
publicclassPublicSubclassPackage:PackageImportClass{} // expected-error {{class cannot be declared public because its superclass is package}}
// expected-note @-1 {{is imported by this file as}}
publicclassPublicSubclassInternal:InternalImportClass{} // expected-error {{class cannot be declared public because its superclass is internal}}
// expected-note @-1 {{is imported by this file as}}
publicclassPublicSubclassFileprivate:FileprivateImportClass{} // expected-error {{class cannot be declared public because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
publicclassPublicSubclassPrivate:PrivateImportClass{} // expected-error {{class cannot be declared public because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoUsesPublic:PublicImportProtowhere T ==PublicImportType{}
packageprotocolPackageProtoWherePackage:PublicImportProtowhere T ==PackageImportType{}
packageprotocolPackageProtoWhereInternal:PublicImportProtowhere T ==InternalImportType{} // expected-error {{package protocol's 'where' clause cannot use an internal struct}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoWhereFileprivate:PublicImportProtowhere T ==FileprivateImportType{} // expected-error {{package protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoWherePrivate:PublicImportProtowhere T ==PrivateImportType{} // expected-error {{package protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoRefinesPublic:PublicImportProto{}
packageprotocolPackageProtoRefinesPackage:PackageImportProto{}
packageprotocolPackageProtoRefinesInternal:InternalImportProto{} // expected-error {{package protocol cannot refine an internal protocol}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoRefinesFileprivate:FileprivateImportProto{} // expected-error {{package protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
packageprotocolPackageProtoRefinesPrivate:PrivateImportProto{} // expected-error {{package protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
packageclassPackageSubclassPublic:PublicImportClass{}
packageclassPackageSubclassPackage:PackageImportClass{}
packageclassPackageSubclassInternal:InternalImportClass{} // expected-error {{class cannot be declared package because its superclass is internal}}
// expected-note @-1 {{is imported by this file as}}
packageclassPackageSubclassFileprivate:FileprivateImportClass{} // expected-error {{class cannot be declared package because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
packageclassPackageSubclassPrivate:PrivateImportClass{} // expected-error {{class cannot be declared package because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
internalprotocolInternalProtoUsesPublic:PublicImportProtowhere T ==PublicImportType{}
internalprotocolInternalProtoWherePackage:PublicImportProtowhere T ==PackageImportType{}
internalprotocolInternalProtoWhereInternal:PublicImportProtowhere T ==InternalImportType{}
internalprotocolInternalProtoWhereFileprivate:PublicImportProtowhere T ==FileprivateImportType{} // expected-error {{internal protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
internalprotocolInternalProtoWherePrivate:PublicImportProtowhere T ==PrivateImportType{} // expected-error {{internal protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
internalprotocolInternalProtoRefinesPublic:PublicImportProto{}
internalprotocolInternalProtoRefinesPackage:PackageImportProto{}
internalprotocolInternalProtoRefinesInternal:InternalImportProto{}
internalprotocolInternalProtoRefinesFileprivate:FileprivateImportProto{} // expected-error {{internal protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
internalprotocolInternalProtoRefinesPrivate:PrivateImportProto{} // expected-error {{internal protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
internalclassInternalSubclassPublic:PublicImportClass{}
internalclassInternalSubclassPackage:PackageImportClass{}
internalclassInternalSubclassInternal:InternalImportClass{}
internalclassInternalSubclassFileprivate:FileprivateImportClass{} // expected-error {{class cannot be declared internal because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
internalclassInternalSubclassPrivate:PrivateImportClass{} // expected-error {{class cannot be declared internal because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
fileprivateprotocolFileprivateProtoUsesPublic:PublicImportProtowhere T ==PublicImportType{}
fileprivateprotocolFileprivateProtoWherePackage:PublicImportProtowhere T ==PackageImportType{}
fileprivateprotocolFileprivateProtoWhereInternal:PublicImportProtowhere T ==InternalImportType{}
fileprivateprotocolFileprivateProtoWhereFileprivate:PublicImportProtowhere T ==FileprivateImportType{}
fileprivateprotocolFileprivateProtoWherePrivate:PublicImportProtowhere T ==PrivateImportType{}
fileprivateprotocolFileprivateProtoRefinesPublic:PublicImportProto{}
fileprivateprotocolFileprivateProtoRefinesPackage:PackageImportProto{}
fileprivateprotocolFileprivateProtoRefinesInternal:InternalImportProto{}
fileprivateprotocolFileprivateProtoRefinesFileprivate:FileprivateImportProto{}
fileprivateprotocolFileprivateProtoRefinesPrivate:PrivateImportProto{}
fileprivateclassFileprivateSubclassPublic:PublicImportClass{}
fileprivateclassFileprivateSubclassPackage:PackageImportClass{}
fileprivateclassFileprivateSubclassInternal:InternalImportClass{}
fileprivateclassFileprivateSubclassFileprivate:FileprivateImportClass{}
fileprivateclassFileprivateSubclassPrivate:PrivateImportClass{}
privateprotocolPrivateProtoUsesPublic:PublicImportProtowhere T ==PublicImportType{}
privateprotocolPrivateProtoWherePackage:PublicImportProtowhere T ==PackageImportType{}
privateprotocolPrivateProtoWhereInternal:PublicImportProtowhere T ==InternalImportType{}
privateprotocolPrivateProtoWhereFileprivate:PublicImportProtowhere T ==FileprivateImportType{}
privateprotocolPrivateProtoWherePrivate:PublicImportProtowhere T ==PrivateImportType{}
privateprotocolPrivateProtoRefinesPublic:PublicImportProto{}
privateprotocolPrivateProtoRefinesPackage:PackageImportProto{}
privateprotocolPrivateProtoRefinesInternal:InternalImportProto{}
privateprotocolPrivateProtoRefinesFileprivate:FileprivateImportProto{}
privateprotocolPrivateProtoRefinesPrivate:PrivateImportProto{}
privateclassPrivateSubclassPublic:PublicImportClass{}
privateclassPrivateSubclassPackage:PackageImportClass{}
privateclassPrivateSubclassInternal:InternalImportClass{}
privateclassPrivateSubclassFileprivate:FileprivateImportClass{}
privateclassPrivateSubclassPrivate:PrivateImportClass{}
publicstructPublicTypeAliasUses{
publictypealiasTAPublic=PublicImportProto
publictypealiasTAPackage=PackageImportProto // expected-error {{type alias cannot be declared public because its underlying type uses a package type}}
// expected-note @-1 {{is imported by this file as}}
publictypealiasTAInternal=InternalImportProto // expected-error {{type alias cannot be declared public because its underlying type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
publictypealiasTAFileprivate=FileprivateImportProto // expected-error {{type alias cannot be declared public because its underlying type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
publictypealiasTAPrivate=PrivateImportProto // expected-error {{type alias cannot be declared public because its underlying type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
packagestructPackageTypeAliasUses{
packagetypealiasTAPublic=PublicImportProto
packagetypealiasTAPackage=PackageImportProto
packagetypealiasTAInternal=InternalImportProto // expected-error {{type alias cannot be declared package because its underlying type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
packagetypealiasTAFileprivate=FileprivateImportProto // expected-error {{type alias cannot be declared package because its underlying type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
packagetypealiasTAPrivate=PrivateImportProto // expected-error {{type alias cannot be declared package because its underlying type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
internalstructInternalTypeAliasUses{
internaltypealiasTAPublic=PublicImportProto
internaltypealiasTAPackage=PackageImportProto
internaltypealiasTAInternal=InternalImportProto
internaltypealiasTAFileprivate=FileprivateImportProto // expected-error {{type alias cannot be declared internal because its underlying type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
internaltypealiasTAPrivate=PrivateImportProto // expected-error {{type alias cannot be declared internal because its underlying type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
fileprivatestructFileprivateTypeAliasUses{
fileprivatetypealiasTAPublic=PublicImportProto
fileprivatetypealiasTAPackage=PackageImportProto
fileprivatetypealiasTAInternal=InternalImportProto
fileprivatetypealiasTAFileprivate=FileprivateImportProto
fileprivatetypealiasTAPrivate=PrivateImportProto
}
privatestructPrivateTypeAliasUses{
privatetypealiasTAPublic=PublicImportProto
privatetypealiasTAPackage=PackageImportProto
privatetypealiasTAInternal=InternalImportProto
privatetypealiasTAFileprivate=FileprivateImportProto
privatetypealiasTAPrivate=PrivateImportProto
}
publicprotocolPublicProtocol{
associatedtypeATDefaultPublic=PublicImportProto
associatedtypeATDefaultPackage=PackageImportProto // expected-error {{associated type in a public protocol uses a package type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultInternal=InternalImportProto // expected-error {{associated type in a public protocol uses an internal type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultFileprivate=FileprivateImportProto // expected-error {{associated type in a public protocol uses a fileprivate type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultPrivate=PrivateImportProto // expected-error {{associated type in a public protocol uses a private type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePublic:PublicImportProto
associatedtypeATRequirePackage:PackageImportProto // expected-error {{associated type in a public protocol uses a package type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequireInternal:InternalImportProto // expected-error {{associated type in a public protocol uses an internal type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequireFileprivate:FileprivateImportProto // expected-error {{associated type in a public protocol uses a fileprivate type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePrivate:PrivateImportProto // expected-error {{associated type in a public protocol uses a private type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
}
packageprotocolPackageProtocol{
associatedtypeATDefaultPublic=PublicImportProto
associatedtypeATDefaultPackage=PackageImportProto
associatedtypeATDefaultInternal=InternalImportProto // expected-error {{associated type in a package protocol uses an internal type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultFileprivate=FileprivateImportProto // expected-error {{associated type in a package protocol uses a fileprivate type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultPrivate=PrivateImportProto // expected-error {{associated type in a package protocol uses a private type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePublic:PublicImportProto
associatedtypeATRequirePackage:PackageImportProto
associatedtypeATRequireInternal:InternalImportProto // expected-error {{associated type in a package protocol uses an internal type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequireFileprivate:FileprivateImportProto // expected-error {{associated type in a package protocol uses a fileprivate type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePrivate:PrivateImportProto // expected-error {{associated type in a package protocol uses a private type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
}
internalprotocolInternalProtocol{
associatedtypeATDefaultPublic=PublicImportProto
associatedtypeATDefaultPackage=PackageImportProto
associatedtypeATDefaultInternal=InternalImportProto
associatedtypeATDefaultFileprivate=FileprivateImportProto // expected-error {{associated type in an internal protocol uses a fileprivate type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATDefaultPrivate=PrivateImportProto // expected-error {{associated type in an internal protocol uses a private type in its default definition}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePublic:PublicImportProto
associatedtypeATRequirePackage:PackageImportProto
associatedtypeATRequireInternal:InternalImportProto
associatedtypeATRequireFileprivate:FileprivateImportProto // expected-error {{associated type in an internal protocol uses a fileprivate type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
associatedtypeATRequirePrivate:PrivateImportProto // expected-error {{associated type in an internal protocol uses a private type in its requirement}}
// expected-note @-1 {{is imported by this file as}}
}
fileprivateprotocolFileprivateProtocol{
associatedtypeATDefaultPublic=PublicImportProto
associatedtypeATDefaultPackage=PackageImportProto
associatedtypeATDefaultInternal=InternalImportProto
associatedtypeATDefaultFileprivate=FileprivateImportProto
// Accocciated type have a minimum formal access level at internal.
associatedtypeATDefaultPrivate=PrivateImportProto
associatedtypeATRequirePublic:PublicImportProto
associatedtypeATRequirePackage:PackageImportProto
associatedtypeATRequireInternal:InternalImportProto
associatedtypeATRequireFileprivate:FileprivateImportProto
associatedtypeATRequirePrivate:PrivateImportProto
}
privateprotocolPrivateProtocol{
associatedtypeATDefaultPublic=PublicImportProto
associatedtypeATDefaultPackage=PackageImportProto
associatedtypeATDefaultInternal=InternalImportProto
associatedtypeATDefaultFileprivate=FileprivateImportProto
associatedtypeATDefaultPrivate=PrivateImportProto
associatedtypeATRequirePublic:PublicImportProto
associatedtypeATRequirePackage:PackageImportProto
associatedtypeATRequireInternal:InternalImportProto
associatedtypeATRequireFileprivate:FileprivateImportProto
associatedtypeATRequirePrivate:PrivateImportProto
}
publicstructPublicVars{
publicvara:PublicImportType
publicvarb:PackageImportType // expected-error {{property cannot be declared public because its type uses a package type}}
// expected-note @-1 {{is imported by this file as}}
publicvarc:InternalImportType // expected-error {{property cannot be declared public because its type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
publicvard:FileprivateImportType // expected-error {{property cannot be declared public because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
publicvare:PrivateImportType // expected-error {{property cannot be declared public because its type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
@PublicLibWrapper
publicvarf:PublicImportType
@PackageLibWrapper
publicvarg:PublicImportType // expected-error {{property cannot be declared public because its property wrapper type uses a package type}}
// expected-note @-1 {{is imported by this file as}}
@InternalLibWrapper
publicvarh:PublicImportType // expected-error {{property cannot be declared public because its property wrapper type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
@FileprivateLibWrapper
publicvari:PublicImportType // expected-error {{property cannot be declared public because its property wrapper type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
@PrivateLibWrapper
publicvarj:PublicImportType // expected-error {{property cannot be declared public because its property wrapper type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
publicvark=PublicImportType()
publicvarl=PackageImportType() // expected-error {{property cannot be declared public because its type 'PackageImportType' uses a package type}}
// expected-note @-1 {{is imported by this file as}}
publicvarm=InternalImportType() // expected-error {{property cannot be declared public because its type 'InternalImportType' uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
publicvarn=FileprivateImportType() // expected-error {{property cannot be declared public because its type 'FileprivateImportType' uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
publicvaro=PrivateImportType() // expected-error {{property cannot be declared public because its type 'PrivateImportType' uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
packagestructPackageVars{
packagevara:PublicImportType
packagevarb:PackageImportType
packagevarc:InternalImportType // expected-error {{property cannot be declared package because its type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
packagevard:FileprivateImportType // expected-error {{property cannot be declared package because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
packagevare:PrivateImportType // expected-error {{property cannot be declared package because its type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
@PublicLibWrapper
packagevarf:PublicImportType
@PackageLibWrapper
packagevarg:PublicImportType
@InternalLibWrapper
packagevarh:PublicImportType // expected-error {{property cannot be declared package because its property wrapper type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
@FileprivateLibWrapper
packagevari:PublicImportType // expected-error {{property cannot be declared package because its property wrapper type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
@PrivateLibWrapper
packagevarj:PublicImportType // expected-error {{property cannot be declared package because its property wrapper type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
packagevark=PublicImportType()
packagevarl=PackageImportType()
packagevarm=InternalImportType() // expected-error {{property cannot be declared package because its type 'InternalImportType' uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
packagevarn=FileprivateImportType() // expected-error {{property cannot be declared package because its type 'FileprivateImportType' uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
packagevaro=PrivateImportType() // expected-error {{property cannot be declared package because its type 'PrivateImportType' uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
internalstructInternalVars{
internalvara:PublicImportType
internalvarb:PackageImportType
internalvarc:InternalImportType
internalvard:FileprivateImportType // expected-error {{property cannot be declared internal because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
internalvare:PrivateImportType // expected-error {{property cannot be declared internal because its type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
@PublicLibWrapper
internalvarf:PublicImportType
@PackageLibWrapper
internalvarg:PublicImportType
@InternalLibWrapper
internalvarh:PublicImportType
@FileprivateLibWrapper
internalvari:PublicImportType // expected-error {{property cannot be declared internal because its property wrapper type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
@PrivateLibWrapper
internalvarj:PublicImportType // expected-error {{property cannot be declared internal because its property wrapper type uses a private type}}
// expected-note @-1 {{is imported by this file as}}
internalvark=PublicImportType()
internalvarl=PackageImportType()
internalvarm=InternalImportType()
internalvarn=FileprivateImportType() // expected-error {{property cannot be declared internal because its type 'FileprivateImportType' uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
internalvaro=PrivateImportType() // expected-error {{property cannot be declared internal because its type 'PrivateImportType' uses a private type}}
// expected-note @-1 {{is imported by this file as}}
}
fileprivatestructFileprivateVars{
fileprivatevara:PublicImportType
fileprivatevarb:PackageImportType
fileprivatevarc:InternalImportType
fileprivatevard:FileprivateImportType
fileprivatevare:PrivateImportType
@PublicLibWrapper
fileprivatevarf:PublicImportType
@PackageLibWrapper
fileprivatevarg:PublicImportType
@InternalLibWrapper
fileprivatevarh:PublicImportType
@FileprivateLibWrapper
fileprivatevari:PublicImportType
@PrivateLibWrapper
fileprivatevarj:PublicImportType
fileprivatevark=PublicImportType()
fileprivatevarl=PackageImportType()
fileprivatevarm=InternalImportType()
fileprivatevarn=FileprivateImportType()
fileprivatevaro=PrivateImportType()
}
privatestructPrivateVars{
privatevara:PublicImportType
privatevarb:PackageImportType
privatevarc:InternalImportType
privatevard:FileprivateImportType
privatevare:PrivateImportType
@PublicLibWrapper
privatevarf:PublicImportType
@PackageLibWrapper
privatevarg:PublicImportType
@InternalLibWrapper
privatevarh:PublicImportType
@FileprivateLibWrapper
privatevari:PublicImportType
@PrivateLibWrapper
privatevarj:PublicImportType
privatevark=PublicImportType()
privatevarl=PackageImportType()
privatevarm=InternalImportType()
privatevarn=FileprivateImportType()
privatevaro=PrivateImportType()
}
publicstructPublicGenericUsesPublic<A:PublicImportProto>{}
publicstructPublicGenericUsesPackage<A:PackageImportProto>{} // expected-error {{generic struct cannot be declared public because its generic parameter uses a package type}}
publicstructPublicGenericUsesInternal<A:InternalImportProto>{} // expected-error {{generic struct cannot be declared public because its generic parameter uses an internal type}}
publicstructPublicGenericUsesFileprivate<A:FileprivateImportProto>{} // expected-error {{generic struct cannot be declared public because its generic parameter uses a fileprivate type}}
publicstructPublicGenericUsesPrivate<A:PrivateImportProto>{} // expected-error {{generic struct cannot be declared public because its generic parameter uses a private type}}
packagestructPackageGenericUsesPublic<A:PublicImportProto>{}
packagestructPackageGenericUsesPackage<A:PackageImportProto>{}
packagestructPackageGenericUsesInternal<A:InternalImportProto>{} // expected-error {{generic struct cannot be declared package because its generic parameter uses an internal type}}
packagestructPackageGenericUsesFileprivate<A:FileprivateImportProto>{} // expected-error {{generic struct cannot be declared package because its generic parameter uses a fileprivate type}}
packagestructPackageGenericUsesPrivate<A:PrivateImportProto>{} // expected-error {{generic struct cannot be declared package because its generic parameter uses a private type}}
internalstructInternalGenericUsesPublic<A:PublicImportProto>{}
internalstructInternalGenericUsesPackage<A:PackageImportProto>{}
internalstructInternalGenericUsesInternal<A:InternalImportProto>{}
internalstructInternalGenericUsesFileprivate<A:FileprivateImportProto>{} // expected-error {{generic struct cannot be declared internal because its generic parameter uses a fileprivate type}}
internalstructInternalGenericUsesPrivate<A:PrivateImportProto>{} // expected-error {{generic struct cannot be declared internal because its generic parameter uses a private type}}
fileprivatestructFileprivateGenericUsesPublic<A:PublicImportProto>{}
fileprivatestructFileprivateGenericUsesPackage<A:PackageImportProto>{}
fileprivatestructFileprivateGenericUsesInternal<A:InternalImportProto>{}
fileprivatestructFileprivateGenericUsesFileprivate<A:FileprivateImportProto>{}
fileprivatestructFileprivateGenericUsesPrivate<A:PrivateImportProto>{}
privatestructPrivateGenericUsesPublic<A:PublicImportProto>{}
privatestructPrivateGenericUsesPackage<A:PackageImportProto>{}
privatestructPrivateGenericUsesInternal<A:InternalImportProto>{}
privatestructPrivateGenericUsesFileprivate<A:FileprivateImportProto>{}
privatestructPrivateGenericUsesPrivate<A:PrivateImportProto>{}
publicstructPublicGenericUsesProtocolComposition<A:FileprivateImportProto&InternalImportProto>{} // expected-error {{generic struct cannot be declared public because its generic parameter uses a fileprivate type}}