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
|
// 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
public protocol PublicImportProto {
associatedtype T
}
public struct PublicImportType {
public init() {}
}
open class PublicImportClass {}
@propertyWrapper
public struct PublicLibWrapper<T> {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
//--- PackageLib.swift
public protocol PackageImportProto {
associatedtype T
}
public struct PackageImportType {
public init() {}
}
open class PackageImportClass {}
@propertyWrapper
public struct PackageLibWrapper<T> {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
//--- InternalLib.swift
public protocol InternalImportProto {
associatedtype T
}
public struct InternalImportType {
public init() {}
}
open class InternalImportClass {}
public func InternalFunc() {}
@propertyWrapper
public struct InternalLibWrapper<T> {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
//--- FileprivateLib.swift
public protocol FileprivateImportProto {
associatedtype T
}
public struct FileprivateImportType {
public init() {}
}
open class FileprivateImportClass {}
@propertyWrapper
public struct FileprivateLibWrapper<T> {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
//--- PrivateLib.swift
public protocol PrivateImportProto {
associatedtype T
}
public struct PrivateImportType {
public init() {}
}
open class PrivateImportClass {}
@propertyWrapper
public struct PrivateLibWrapper<T> {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
/// Short test mostly to count the notes.
//--- MinimalClient.swift
public import PublicLib // expected-warning {{public import of 'PublicLib' was not used in public declarations or inlinable code}}
package import PackageLib // expected-warning {{package import of 'PackageLib' was not used in package declarations}}
internal import InternalLib // expected-note {{struct 'InternalImportType' imported as 'internal' from 'InternalLib' here}}
fileprivate import FileprivateLib // expected-note {{class 'FileprivateImportClass' imported as 'fileprivate' from 'FileprivateLib' here}}
private import PrivateLib
public func 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
}
public class PublicSubclassFileprivate : 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
public import PublicLib
package import PackageLib // expected-note * {{module 'PackageLib' imported as 'package' here}}
// expected-note@-1 * {{imported as 'package' from 'PackageLib' here}}
internal import InternalLib // expected-note * {{module 'InternalLib' imported as 'internal' here}}
// expected-note@-1 * {{imported as 'internal' from 'InternalLib' here}}
fileprivate import FileprivateLib // expected-note * {{module 'FileprivateLib' imported as 'fileprivate' here}}
// expected-note@-1 * {{imported as 'fileprivate' from 'FileprivateLib' here}}
private import PrivateLib // expected-note * {{module 'PrivateLib' imported as 'private' here}}
// expected-note@-1 * {{imported as 'private' from 'PrivateLib' here}}
// Public use sites
public func PublicFuncUsesPublic(_: PublicImportType) {
var _: PublicImportType
}
public func 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
}
public func 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
}
public func 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
}
public func 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
package func PackageFuncUsesPublic(_: PublicImportType) {
var _: PublicImportType
}
package func PackageFuncUsesPackage(_: PackageImportType) {
var _: PackageImportType
}
package func 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
}
package func 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
}
package func 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
internal func InternalFuncUsesPublic(_: PublicImportType) {
var _: PublicImportType
}
internal func InternalFuncUsesPackage(_: PackageImportType) {
var _: PackageImportType
}
internal func InternalFuncUsesInternal(_: InternalImportType) {
var _: InternalImportType
}
internal func 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
}
internal func 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
fileprivate func FileprivateFuncUsesPublic(_: PublicImportType) {
var _: PublicImportType
}
fileprivate func FileprivateFuncUsesPackage(_: PackageImportType) {
var _: PackageImportType
}
fileprivate func FileprivateFuncUsesInternal(_: InternalImportType) {
var _: InternalImportType
}
fileprivate func FileprivateFuncUsesFileprivate(_: FileprivateImportType) {
var _: FileprivateImportType
}
fileprivate func FileprivateFuncUsesPrivate(_: PrivateImportType) {
var _: PrivateImportType
}
// Private use sites
private func PrivateFuncUsesPublic(_: PublicImportType) {
var _: PublicImportType
}
private func PrivateFuncUsesPackage(_: PackageImportType) {
var _: PackageImportType
}
private func PrivateFuncUsesInternal(_: InternalImportType) {
var _: InternalImportType
}
private func PrivateFuncUsesFileprivate(_: FileprivateImportType) {
var _: FileprivateImportType
}
private func PrivateFuncUsesPrivate(_: PrivateImportType) {
var _: PrivateImportType
}
// Public returns
public func PublicFuncReturnUsesPublic() -> PublicImportType {
fatalError()
}
public func 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()
}
public func 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()
}
public func 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()
}
public func 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
package func PackageFuncReturnUsesPublic() -> PublicImportType {
fatalError()
}
package func PackageFuncReturnUsesPackage() -> PackageImportType {
fatalError()
}
package func 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()
}
package func 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()
}
package func 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
internal func InternalFuncReturnUsesPublic() -> PublicImportType {
fatalError()
}
internal func InternalFuncReturnUsesPackage() -> PackageImportType {
fatalError()
}
internal func InternalFuncReturnUsesInternal() -> InternalImportType {
fatalError()
}
internal func 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()
}
internal func 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
fileprivate func FileprivateFuncReturnUsesPublic() -> PublicImportType {
fatalError()
}
fileprivate func FileprivateFuncReturnUsesPackage() -> PackageImportType {
fatalError()
}
fileprivate func FileprivateFuncReturnUsesInternal() -> InternalImportType {
fatalError()
}
fileprivate func FileprivateFuncReturnUsesFileprivate() -> FileprivateImportType {
fatalError()
}
fileprivate func FileprivateFuncReturnUsesPrivate() -> PrivateImportType {
fatalError()
}
// Private returns
private func PrivateFuncReturnUsesPublic() -> PublicImportType {
fatalError()
}
private func PrivateFuncReturnUsesPackage() -> PackageImportType {
fatalError()
}
private func PrivateFuncReturnUsesInternal() -> InternalImportType {
fatalError()
}
private func PrivateFuncReturnUsesFileprivate() -> FileprivateImportType {
fatalError()
}
private func PrivateFuncReturnUsesPrivate() -> PrivateImportType {
fatalError()
}
// Public subscripts
public struct PublicSubscriptUsesPublic {
public subscript(index: PublicImportType) -> PublicImportType {
fatalError()
}
}
public struct PublicSubscriptUsesPackage {
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()
}
}
public struct PublicSubscriptUsesInternal {
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()
}
}
public struct PublicSubscriptUsesFileprivate {
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()
}
}
public struct PublicSubscriptUsesPrivate {
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
package struct PackageSubscriptUsesPublic {
package subscript(index: PublicImportType) -> PublicImportType {
fatalError()
}
}
package struct PackageSubscriptUsesPackage {
package subscript(index: PackageImportType) -> PackageImportType {
fatalError()
}
}
package struct PackageSubscriptUsesInternal {
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()
}
}
package struct PackageSubscriptUsesFileprivate {
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()
}
}
package struct PackageSubscriptUsesPrivate {
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
internal struct InternalSubscriptUsesPublic {
internal subscript(index: PublicImportType) -> PublicImportType {
fatalError()
}
}
internal struct InternalSubscriptUsesPackage {
internal subscript(index: PackageImportType) -> PackageImportType {
fatalError()
}
}
internal struct InternalSubscriptUsesInternal {
internal subscript(index: InternalImportType) -> InternalImportType {
fatalError()
}
}
internal struct InternalSubscriptUsesFileprivate {
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()
}
}
internal struct InternalSubscriptUsesPrivate {
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
fileprivate struct FileprivateSubscriptUsesPublic {
fileprivate subscript(index: PublicImportType) -> PublicImportType {
fatalError()
}
}
fileprivate struct FileprivateSubscriptUsesPackage {
fileprivate subscript(index: PackageImportType) -> PackageImportType {
fatalError()
}
}
fileprivate struct FileprivateSubscriptUsesInternal {
fileprivate subscript(index: InternalImportType) -> InternalImportType {
fatalError()
}
}
fileprivate struct FileprivateSubscriptUsesFileprivate {
fileprivate subscript(index: FileprivateImportType) -> FileprivateImportType {
fatalError()
}
}
fileprivate struct FileprivateSubscriptUsesPrivate {
fileprivate subscript(index: PrivateImportType) -> PrivateImportType {
fatalError()
}
}
// Private subscripts
private struct PrivateSubscriptUsesPublic {
private subscript(index: PublicImportType) -> PublicImportType {
fatalError()
}
}
private struct PrivateSubscriptUsesPackage {
private subscript(index: PackageImportType) -> PackageImportType {
fatalError()
}
}
private struct PrivateSubscriptUsesInternal {
private subscript(index: InternalImportType) -> InternalImportType {
fatalError()
}
}
private struct PrivateSubscriptUsesFileprivate {
private subscript(index: FileprivateImportType) -> FileprivateImportType {
fatalError()
}
}
private struct PrivateSubscriptUsesPrivate {
private subscript(index: PrivateImportType) -> PrivateImportType {
fatalError()
}
}
public protocol PublicProtoUsesPublic: PublicImportProto where T == PublicImportType {}
public protocol PublicProtoWherePackage: PublicImportProto where T == PackageImportType {} // expected-error {{public protocol's 'where' clause cannot use a package struct}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoWhereInternal: PublicImportProto where T == InternalImportType {} // expected-error {{public protocol's 'where' clause cannot use an internal struct}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoWhereFileprivate: PublicImportProto where T == FileprivateImportType {} // expected-error {{public protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoWherePrivate: PublicImportProto where T == PrivateImportType {} // expected-error {{public protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoRefinesPublic: PublicImportProto {}
public protocol PublicProtoRefinesPackage: PackageImportProto {} // expected-error {{public protocol cannot refine a package protocol}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoRefinesInternal: InternalImportProto {} // expected-error {{public protocol cannot refine an internal protocol}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoRefinesFileprivate: FileprivateImportProto {} // expected-error {{public protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
public protocol PublicProtoRefinesPrivate: PrivateImportProto {} // expected-error {{public protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
public class PublicSubclassPublic : PublicImportClass {}
public class PublicSubclassPackage : PackageImportClass {} // expected-error {{class cannot be declared public because its superclass is package}}
// expected-note @-1 {{is imported by this file as}}
public class PublicSubclassInternal : InternalImportClass {} // expected-error {{class cannot be declared public because its superclass is internal}}
// expected-note @-1 {{is imported by this file as}}
public class PublicSubclassFileprivate : FileprivateImportClass {} // expected-error {{class cannot be declared public because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
public class PublicSubclassPrivate : PrivateImportClass {} // expected-error {{class cannot be declared public because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoUsesPublic: PublicImportProto where T == PublicImportType {}
package protocol PackageProtoWherePackage: PublicImportProto where T == PackageImportType {}
package protocol PackageProtoWhereInternal: PublicImportProto where T == InternalImportType {} // expected-error {{package protocol's 'where' clause cannot use an internal struct}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoWhereFileprivate: PublicImportProto where T == FileprivateImportType {} // expected-error {{package protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoWherePrivate: PublicImportProto where T == PrivateImportType {} // expected-error {{package protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoRefinesPublic: PublicImportProto {}
package protocol PackageProtoRefinesPackage: PackageImportProto {}
package protocol PackageProtoRefinesInternal: InternalImportProto {} // expected-error {{package protocol cannot refine an internal protocol}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoRefinesFileprivate: FileprivateImportProto {} // expected-error {{package protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
package protocol PackageProtoRefinesPrivate: PrivateImportProto {} // expected-error {{package protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
package class PackageSubclassPublic : PublicImportClass {}
package class PackageSubclassPackage : PackageImportClass {}
package class PackageSubclassInternal : InternalImportClass {} // expected-error {{class cannot be declared package because its superclass is internal}}
// expected-note @-1 {{is imported by this file as}}
package class PackageSubclassFileprivate : FileprivateImportClass {} // expected-error {{class cannot be declared package because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
package class PackageSubclassPrivate : PrivateImportClass {} // expected-error {{class cannot be declared package because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
internal protocol InternalProtoUsesPublic: PublicImportProto where T == PublicImportType {}
internal protocol InternalProtoWherePackage: PublicImportProto where T == PackageImportType {}
internal protocol InternalProtoWhereInternal: PublicImportProto where T == InternalImportType {}
internal protocol InternalProtoWhereFileprivate: PublicImportProto where T == FileprivateImportType {} // expected-error {{internal protocol's 'where' clause cannot use a fileprivate struct}}
// expected-note @-1 {{is imported by this file as}}
internal protocol InternalProtoWherePrivate: PublicImportProto where T == PrivateImportType {} // expected-error {{internal protocol's 'where' clause cannot use a private struct}}
// expected-note @-1 {{is imported by this file as}}
internal protocol InternalProtoRefinesPublic: PublicImportProto {}
internal protocol InternalProtoRefinesPackage: PackageImportProto {}
internal protocol InternalProtoRefinesInternal: InternalImportProto {}
internal protocol InternalProtoRefinesFileprivate: FileprivateImportProto {} // expected-error {{internal protocol cannot refine a fileprivate protocol}}
// expected-note @-1 {{is imported by this file as}}
internal protocol InternalProtoRefinesPrivate: PrivateImportProto {} // expected-error {{internal protocol cannot refine a private protocol}}
// expected-note @-1 {{is imported by this file as}}
internal class InternalSubclassPublic : PublicImportClass {}
internal class InternalSubclassPackage : PackageImportClass {}
internal class InternalSubclassInternal : InternalImportClass {}
internal class InternalSubclassFileprivate : FileprivateImportClass {} // expected-error {{class cannot be declared internal because its superclass is fileprivate}}
// expected-note @-1 {{is imported by this file as}}
internal class InternalSubclassPrivate : PrivateImportClass {} // expected-error {{class cannot be declared internal because its superclass is private}}
// expected-note @-1 {{is imported by this file as}}
fileprivate protocol FileprivateProtoUsesPublic: PublicImportProto where T == PublicImportType {}
fileprivate protocol FileprivateProtoWherePackage: PublicImportProto where T == PackageImportType {}
fileprivate protocol FileprivateProtoWhereInternal: PublicImportProto where T == InternalImportType {}
fileprivate protocol FileprivateProtoWhereFileprivate: PublicImportProto where T == FileprivateImportType {}
fileprivate protocol FileprivateProtoWherePrivate: PublicImportProto where T == PrivateImportType {}
fileprivate protocol FileprivateProtoRefinesPublic: PublicImportProto {}
fileprivate protocol FileprivateProtoRefinesPackage: PackageImportProto {}
fileprivate protocol FileprivateProtoRefinesInternal: InternalImportProto {}
fileprivate protocol FileprivateProtoRefinesFileprivate: FileprivateImportProto {}
fileprivate protocol FileprivateProtoRefinesPrivate: PrivateImportProto {}
fileprivate class FileprivateSubclassPublic : PublicImportClass {}
fileprivate class FileprivateSubclassPackage : PackageImportClass {}
fileprivate class FileprivateSubclassInternal : InternalImportClass {}
fileprivate class FileprivateSubclassFileprivate : FileprivateImportClass {}
fileprivate class FileprivateSubclassPrivate : PrivateImportClass {}
private protocol PrivateProtoUsesPublic: PublicImportProto where T == PublicImportType {}
private protocol PrivateProtoWherePackage: PublicImportProto where T == PackageImportType {}
private protocol PrivateProtoWhereInternal: PublicImportProto where T == InternalImportType {}
private protocol PrivateProtoWhereFileprivate: PublicImportProto where T == FileprivateImportType {}
private protocol PrivateProtoWherePrivate: PublicImportProto where T == PrivateImportType {}
private protocol PrivateProtoRefinesPublic: PublicImportProto {}
private protocol PrivateProtoRefinesPackage: PackageImportProto {}
private protocol PrivateProtoRefinesInternal: InternalImportProto {}
private protocol PrivateProtoRefinesFileprivate: FileprivateImportProto {}
private protocol PrivateProtoRefinesPrivate: PrivateImportProto {}
private class PrivateSubclassPublic : PublicImportClass {}
private class PrivateSubclassPackage : PackageImportClass {}
private class PrivateSubclassInternal : InternalImportClass {}
private class PrivateSubclassFileprivate : FileprivateImportClass {}
private class PrivateSubclassPrivate : PrivateImportClass {}
public struct PublicTypeAliasUses {
public typealias TAPublic = PublicImportProto
public typealias TAPackage = 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}}
public typealias TAInternal = 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}}
public typealias TAFileprivate = 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}}
public typealias TAPrivate = 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}}
}
package struct PackageTypeAliasUses {
package typealias TAPublic = PublicImportProto
package typealias TAPackage = PackageImportProto
package typealias TAInternal = 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}}
package typealias TAFileprivate = 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}}
package typealias TAPrivate = 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}}
}
internal struct InternalTypeAliasUses {
internal typealias TAPublic = PublicImportProto
internal typealias TAPackage = PackageImportProto
internal typealias TAInternal = InternalImportProto
internal typealias TAFileprivate = 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}}
internal typealias TAPrivate = 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}}
}
fileprivate struct FileprivateTypeAliasUses {
fileprivate typealias TAPublic = PublicImportProto
fileprivate typealias TAPackage = PackageImportProto
fileprivate typealias TAInternal = InternalImportProto
fileprivate typealias TAFileprivate = FileprivateImportProto
fileprivate typealias TAPrivate = PrivateImportProto
}
private struct PrivateTypeAliasUses {
private typealias TAPublic = PublicImportProto
private typealias TAPackage = PackageImportProto
private typealias TAInternal = InternalImportProto
private typealias TAFileprivate = FileprivateImportProto
private typealias TAPrivate = PrivateImportProto
}
public protocol PublicProtocol {
associatedtype ATDefaultPublic = PublicImportProto
associatedtype ATDefaultPackage = 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}}
associatedtype ATDefaultInternal = 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}}
associatedtype ATDefaultFileprivate = 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}}
associatedtype ATDefaultPrivate = 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}}
associatedtype ATRequirePublic: PublicImportProto
associatedtype ATRequirePackage: 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}}
associatedtype ATRequireInternal: 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}}
associatedtype ATRequireFileprivate: 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}}
associatedtype ATRequirePrivate: 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}}
}
package protocol PackageProtocol {
associatedtype ATDefaultPublic = PublicImportProto
associatedtype ATDefaultPackage = PackageImportProto
associatedtype ATDefaultInternal = 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}}
associatedtype ATDefaultFileprivate = 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}}
associatedtype ATDefaultPrivate = 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}}
associatedtype ATRequirePublic: PublicImportProto
associatedtype ATRequirePackage: PackageImportProto
associatedtype ATRequireInternal: 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}}
associatedtype ATRequireFileprivate: 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}}
associatedtype ATRequirePrivate: 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}}
}
internal protocol InternalProtocol {
associatedtype ATDefaultPublic = PublicImportProto
associatedtype ATDefaultPackage = PackageImportProto
associatedtype ATDefaultInternal = InternalImportProto
associatedtype ATDefaultFileprivate = 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}}
associatedtype ATDefaultPrivate = 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}}
associatedtype ATRequirePublic: PublicImportProto
associatedtype ATRequirePackage: PackageImportProto
associatedtype ATRequireInternal: InternalImportProto
associatedtype ATRequireFileprivate: 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}}
associatedtype ATRequirePrivate: 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}}
}
fileprivate protocol FileprivateProtocol {
associatedtype ATDefaultPublic = PublicImportProto
associatedtype ATDefaultPackage = PackageImportProto
associatedtype ATDefaultInternal = InternalImportProto
associatedtype ATDefaultFileprivate = FileprivateImportProto
// Accocciated type have a minimum formal access level at internal.
associatedtype ATDefaultPrivate = PrivateImportProto
associatedtype ATRequirePublic: PublicImportProto
associatedtype ATRequirePackage: PackageImportProto
associatedtype ATRequireInternal: InternalImportProto
associatedtype ATRequireFileprivate: FileprivateImportProto
associatedtype ATRequirePrivate: PrivateImportProto
}
private protocol PrivateProtocol {
associatedtype ATDefaultPublic = PublicImportProto
associatedtype ATDefaultPackage = PackageImportProto
associatedtype ATDefaultInternal = InternalImportProto
associatedtype ATDefaultFileprivate = FileprivateImportProto
associatedtype ATDefaultPrivate = PrivateImportProto
associatedtype ATRequirePublic: PublicImportProto
associatedtype ATRequirePackage: PackageImportProto
associatedtype ATRequireInternal: InternalImportProto
associatedtype ATRequireFileprivate: FileprivateImportProto
associatedtype ATRequirePrivate: PrivateImportProto
}
public struct PublicVars {
public var a: PublicImportType
public var b: PackageImportType // expected-error {{property cannot be declared public because its type uses a package type}}
// expected-note @-1 {{is imported by this file as}}
public var c: InternalImportType // expected-error {{property cannot be declared public because its type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
public var d: FileprivateImportType // expected-error {{property cannot be declared public because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
public var e: 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
public var f: PublicImportType
@PackageLibWrapper
public var g: 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
public var h: 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
public var i: 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
public var j: 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}}
public var k = PublicImportType()
public var l = PackageImportType() // expected-error {{property cannot be declared public because its type 'PackageImportType' uses a package type}}
public var m = InternalImportType() // expected-error {{property cannot be declared public because its type 'InternalImportType' uses an internal type}}
public var n = FileprivateImportType() // expected-error {{property cannot be declared public because its type 'FileprivateImportType' uses a fileprivate type}}
public var o = PrivateImportType() // expected-error {{property cannot be declared public because its type 'PrivateImportType' uses a private type}}
}
package struct PackageVars {
package var a: PublicImportType
package var b: PackageImportType
package var c: InternalImportType // expected-error {{property cannot be declared package because its type uses an internal type}}
// expected-note @-1 {{is imported by this file as}}
package var d: FileprivateImportType // expected-error {{property cannot be declared package because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
package var e: 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
package var f: PublicImportType
@PackageLibWrapper
package var g: PublicImportType
@InternalLibWrapper
package var h: 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
package var i: 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
package var j: 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}}
package var k = PublicImportType()
package var l = PackageImportType()
package var m = InternalImportType() // expected-error {{property cannot be declared package because its type 'InternalImportType' uses an internal type}}
package var n = FileprivateImportType() // expected-error {{property cannot be declared package because its type 'FileprivateImportType' uses a fileprivate type}}
package var o = PrivateImportType() // expected-error {{property cannot be declared package because its type 'PrivateImportType' uses a private type}}
}
internal struct InternalVars {
internal var a: PublicImportType
internal var b: PackageImportType
internal var c: InternalImportType
internal var d: FileprivateImportType // expected-error {{property cannot be declared internal because its type uses a fileprivate type}}
// expected-note @-1 {{is imported by this file as}}
internal var e: 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
internal var f: PublicImportType
@PackageLibWrapper
internal var g: PublicImportType
@InternalLibWrapper
internal var h: PublicImportType
@FileprivateLibWrapper
internal var i: 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
internal var j: 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}}
internal var k = PublicImportType()
internal var l = PackageImportType()
internal var m = InternalImportType()
internal var n = FileprivateImportType() // expected-error {{property cannot be declared internal because its type 'FileprivateImportType' uses a fileprivate type}}
internal var o = PrivateImportType() // expected-error {{property cannot be declared internal because its type 'PrivateImportType' uses a private type}}
}
fileprivate struct FileprivateVars {
fileprivate var a: PublicImportType
fileprivate var b: PackageImportType
fileprivate var c: InternalImportType
fileprivate var d: FileprivateImportType
fileprivate var e: PrivateImportType
@PublicLibWrapper
fileprivate var f: PublicImportType
@PackageLibWrapper
fileprivate var g: PublicImportType
@InternalLibWrapper
fileprivate var h: PublicImportType
@FileprivateLibWrapper
fileprivate var i: PublicImportType
@PrivateLibWrapper
fileprivate var j: PublicImportType
fileprivate var k = PublicImportType()
fileprivate var l = PackageImportType()
fileprivate var m = InternalImportType()
fileprivate var n = FileprivateImportType()
fileprivate var o = PrivateImportType()
}
private struct PrivateVars {
private var a: PublicImportType
private var b: PackageImportType
private var c: InternalImportType
private var d: FileprivateImportType
private var e: PrivateImportType
@PublicLibWrapper
private var f: PublicImportType
@PackageLibWrapper
private var g: PublicImportType
@InternalLibWrapper
private var h: PublicImportType
@FileprivateLibWrapper
private var i: PublicImportType
@PrivateLibWrapper
private var j: PublicImportType
private var k = PublicImportType()
private var l = PackageImportType()
private var m = InternalImportType()
private var n = FileprivateImportType()
private var o = PrivateImportType()
}
public struct PublicGenericUsesPublic<A: PublicImportProto> {}
public struct PublicGenericUsesPackage<A: PackageImportProto> {} // expected-error {{generic struct cannot be declared public because its generic parameter uses a package type}}
public struct PublicGenericUsesInternal<A: InternalImportProto> {} // expected-error {{generic struct cannot be declared public because its generic parameter uses an internal type}}
public struct PublicGenericUsesFileprivate<A: FileprivateImportProto> {} // expected-error {{generic struct cannot be declared public because its generic parameter uses a fileprivate type}}
public struct PublicGenericUsesPrivate<A: PrivateImportProto> {} // expected-error {{generic struct cannot be declared public because its generic parameter uses a private type}}
package struct PackageGenericUsesPublic<A: PublicImportProto> {}
package struct PackageGenericUsesPackage<A: PackageImportProto> {}
package struct PackageGenericUsesInternal<A: InternalImportProto> {} // expected-error {{generic struct cannot be declared package because its generic parameter uses an internal type}}
package struct PackageGenericUsesFileprivate<A: FileprivateImportProto> {} // expected-error {{generic struct cannot be declared package because its generic parameter uses a fileprivate type}}
package struct PackageGenericUsesPrivate<A: PrivateImportProto> {} // expected-error {{generic struct cannot be declared package because its generic parameter uses a private type}}
internal struct InternalGenericUsesPublic<A: PublicImportProto> {}
internal struct InternalGenericUsesPackage<A: PackageImportProto> {}
internal struct InternalGenericUsesInternal<A: InternalImportProto> {}
internal struct InternalGenericUsesFileprivate<A: FileprivateImportProto> {} // expected-error {{generic struct cannot be declared internal because its generic parameter uses a fileprivate type}}
internal struct InternalGenericUsesPrivate<A: PrivateImportProto> {} // expected-error {{generic struct cannot be declared internal because its generic parameter uses a private type}}
fileprivate struct FileprivateGenericUsesPublic<A: PublicImportProto> {}
fileprivate struct FileprivateGenericUsesPackage<A: PackageImportProto> {}
fileprivate struct FileprivateGenericUsesInternal<A: InternalImportProto> {}
fileprivate struct FileprivateGenericUsesFileprivate<A: FileprivateImportProto> {}
fileprivate struct FileprivateGenericUsesPrivate<A: PrivateImportProto> {}
private struct PrivateGenericUsesPublic<A: PublicImportProto> {}
private struct PrivateGenericUsesPackage<A: PackageImportProto> {}
private struct PrivateGenericUsesInternal<A: InternalImportProto> {}
private struct PrivateGenericUsesFileprivate<A: FileprivateImportProto> {}
private struct PrivateGenericUsesPrivate<A: PrivateImportProto> {}
public struct PublicGenericUsesProtocolComposition<A: FileprivateImportProto & InternalImportProto> {} // expected-error {{generic struct cannot be declared public because its generic parameter uses a fileprivate type}}
|