|
10 | 10 |
|
11 | 11 | // Primary execution of this test. Uses the default minimum inlining version,
|
12 | 12 | // which is the version when Swift was introduced.
|
13 |
| -// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version min |
| 13 | +// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -parse-as-library -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version min |
14 | 14 |
|
15 | 15 |
|
16 | 16 | // Check that `-library-level api` implies `-target-min-inlining-version min`
|
17 |
| -// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -library-level api -require-explicit-availability=ignore |
| 17 | +// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -parse-as-library -module-name Test -target %target-next-stable-abi-triple -library-level api -require-explicit-availability=ignore |
18 | 18 |
|
19 | 19 |
|
20 | 20 | // Check that these rules are only applied when requested and that at least some
|
21 | 21 | // diagnostics are not present without it.
|
22 |
| -// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_MIN %s |
| 22 | +// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -parse-as-library -module-name Test -target %target-next-stable-abi-triple 2>&1 | %FileCheck --check-prefix NON_MIN %s |
23 | 23 |
|
24 | 24 |
|
25 | 25 | // Check that -target-min-inlining-version overrides -library-level, allowing
|
26 | 26 | // library owners to disable this behavior for API libraries if needed.
|
27 |
| -// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version target -library-level api -require-explicit-availability=ignore 2>&1 | %FileCheck --check-prefix NON_MIN %s |
| 27 | +// RUN: not %target-typecheck-verify-swift -swift-version 5 -enable-library-evolution -parse-as-library -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version target -library-level api -require-explicit-availability=ignore 2>&1 | %FileCheck --check-prefix NON_MIN %s |
28 | 28 |
|
29 | 29 |
|
30 | 30 | // Check that we respect -target-min-inlining-version by cranking it up high
|
31 | 31 | // enough to suppress any possible errors.
|
32 |
| -// RUN: %target-swift-frontend -typecheck -disable-objc-attr-requires-foundation-module %s -swift-version 5 -enable-library-evolution -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version 42.0 |
| 32 | +// RUN: %target-swift-frontend -typecheck -disable-objc-attr-requires-foundation-module %s -swift-version 5 -enable-library-evolution -parse-as-library -module-name Test -target %target-next-stable-abi-triple -target-min-inlining-version 42.0 |
33 | 33 |
|
34 | 34 |
|
35 | 35 | // NON_MIN: error: expected error not produced
|
@@ -579,6 +579,143 @@ public func spiDeployedUseNoAvailable( // expected-note 3 {{add @available attri
|
579 | 579 | }
|
580 | 580 | }
|
581 | 581 |
|
| 582 | +// MARK: - @inlinable global property accessors |
| 583 | + |
| 584 | +@inlinable public var inlinedNoAvailableGlobal: Any { // expected-note 3 {{add @available attribute to enclosing var}} |
| 585 | + _ = NoAvailable() |
| 586 | + _ = BeforeInliningTarget() |
| 587 | + _ = AtInliningTarget() |
| 588 | + _ = BetweenTargets() // expected-error {{'BetweenTargets' is only available in macOS 10.14.5 or newer; clients of 'Test' may have a lower deployment target}} expected-note {{add 'if #available' version check}} |
| 589 | + _ = AtDeploymentTarget() // expected-error {{'AtDeploymentTarget' is only available in macOS 10.15 or newer; clients of 'Test' may have a lower deployment target}} expected-note {{add 'if #available' version check}} |
| 590 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 591 | + |
| 592 | + if #available(macOS 11, *) { |
| 593 | + _ = AfterDeploymentTarget() |
| 594 | + } |
| 595 | + |
| 596 | + return () |
| 597 | +} |
| 598 | + |
| 599 | +@inlinable public var inlinedNoAvailableGlobalExplicitGetter: Any { // expected-note 3 {{add @available attribute to enclosing var}} |
| 600 | + get { |
| 601 | + _ = NoAvailable() |
| 602 | + _ = BeforeInliningTarget() |
| 603 | + _ = AtInliningTarget() |
| 604 | + _ = BetweenTargets() // expected-error {{'BetweenTargets' is only available in macOS 10.14.5 or newer; clients of 'Test' may have a lower deployment target}} expected-note {{add 'if #available' version check}} |
| 605 | + _ = AtDeploymentTarget() // expected-error {{'AtDeploymentTarget' is only available in macOS 10.15 or newer; clients of 'Test' may have a lower deployment target}} expected-note {{add 'if #available' version check}} |
| 606 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 607 | + |
| 608 | + if #available(macOS 11, *) { |
| 609 | + _ = AfterDeploymentTarget() |
| 610 | + } |
| 611 | + |
| 612 | + return () |
| 613 | + } |
| 614 | +} |
| 615 | + |
| 616 | +@available(macOS 10.15, *) |
| 617 | +@inlinable public var inlinedAtDeploymentTargetGlobal: Any { |
| 618 | + _ = NoAvailable() |
| 619 | + _ = BeforeInliningTarget() |
| 620 | + _ = AtInliningTarget() |
| 621 | + _ = BetweenTargets() |
| 622 | + _ = AtDeploymentTarget() |
| 623 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 624 | + |
| 625 | + if #available(macOS 11, *) { |
| 626 | + _ = AfterDeploymentTarget() |
| 627 | + } |
| 628 | + |
| 629 | + return () |
| 630 | +} |
| 631 | + |
| 632 | +@inlinable public var inlinedGlobalGetterAtDeploymentTarget: Any { // expected-note {{add @available attribute to enclosing var}} |
| 633 | + @available(macOS 10.15, *) |
| 634 | + get { |
| 635 | + _ = NoAvailable() |
| 636 | + _ = BeforeInliningTarget() |
| 637 | + _ = AtInliningTarget() |
| 638 | + _ = BetweenTargets() |
| 639 | + _ = AtDeploymentTarget() |
| 640 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 641 | + |
| 642 | + if #available(macOS 11, *) { |
| 643 | + _ = AfterDeploymentTarget() |
| 644 | + } |
| 645 | + |
| 646 | + return () |
| 647 | + } |
| 648 | +} |
| 649 | + |
| 650 | +@_spi(Private) |
| 651 | +@inlinable public var inlinedNoAvailableSPIGlobal: Any { // expected-note {{add @available attribute to enclosing var}} |
| 652 | + _ = NoAvailable() |
| 653 | + _ = BeforeInliningTarget() |
| 654 | + _ = AtInliningTarget() |
| 655 | + _ = BetweenTargets() |
| 656 | + _ = AtDeploymentTarget() |
| 657 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 658 | + |
| 659 | + if #available(macOS 11, *) { |
| 660 | + _ = AfterDeploymentTarget() |
| 661 | + } |
| 662 | + |
| 663 | + return () |
| 664 | +} |
| 665 | + |
| 666 | +@inlinable public var inlinedNoAvailableGlobalSPISetter: Any { // expected-note {{add @available attribute to enclosing var}} |
| 667 | + get { |
| 668 | + fatalError() |
| 669 | + } |
| 670 | + @_spi(Private) |
| 671 | + set { |
| 672 | + _ = NoAvailable() |
| 673 | + _ = BeforeInliningTarget() |
| 674 | + _ = AtInliningTarget() |
| 675 | + _ = BetweenTargets() |
| 676 | + _ = AtDeploymentTarget() |
| 677 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 678 | + |
| 679 | + if #available(macOS 11, *) { |
| 680 | + _ = AfterDeploymentTarget() |
| 681 | + } |
| 682 | + } |
| 683 | +} |
| 684 | + |
| 685 | +@available(macOS, unavailable) |
| 686 | +@inlinable public var inlinedUnavailableGlobal: Any { |
| 687 | + _ = NoAvailable() |
| 688 | + _ = BeforeInliningTarget() |
| 689 | + _ = AtInliningTarget() |
| 690 | + _ = BetweenTargets() |
| 691 | + _ = AtDeploymentTarget() |
| 692 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 693 | + |
| 694 | + if #available(macOS 11, *) { |
| 695 | + _ = AfterDeploymentTarget() |
| 696 | + } |
| 697 | + |
| 698 | + return () |
| 699 | +} |
| 700 | + |
| 701 | +@inlinable public var inlinedNoAvailableGlobalUnavailableSetter: Any { // expected-note {{add @available attribute to enclosing var}} |
| 702 | + get { |
| 703 | + fatalError() |
| 704 | + } |
| 705 | + @available(macOS, unavailable) |
| 706 | + set { |
| 707 | + _ = NoAvailable() |
| 708 | + _ = BeforeInliningTarget() |
| 709 | + _ = AtInliningTarget() |
| 710 | + _ = BetweenTargets() |
| 711 | + _ = AtDeploymentTarget() |
| 712 | + _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
| 713 | + |
| 714 | + if #available(macOS 11, *) { |
| 715 | + _ = AfterDeploymentTarget() |
| 716 | + } |
| 717 | + } |
| 718 | +} |
582 | 719 |
|
583 | 720 | // MARK: - @_alwaysEmitIntoClient functions
|
584 | 721 |
|
@@ -1467,23 +1604,3 @@ public enum UnavailableEnumWithClasses {
|
1467 | 1604 | public class InheritsAfterDeploymentTarget: AfterDeploymentTargetClass {} // expected-error {{'AfterDeploymentTargetClass' is only available in}} expected-note 2 {{add @available attribute to enclosing class}}
|
1468 | 1605 | public class InheritsUnavailable: UnavailableClass {}
|
1469 | 1606 | }
|
1470 |
| - |
1471 |
| -// MARK: - Top-level code |
1472 |
| - |
1473 |
| -// Top-level code, if somehow present in a resilient module, is treated like |
1474 |
| -// a non-inlinable function. |
1475 |
| -defer { |
1476 |
| - _ = AtDeploymentTarget() |
1477 |
| - _ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
1478 |
| -} |
1479 |
| -_ = NoAvailable() |
1480 |
| -_ = BeforeInliningTarget() |
1481 |
| -_ = AtInliningTarget() |
1482 |
| -_ = BetweenTargets() |
1483 |
| -_ = AtDeploymentTarget() |
1484 |
| -_ = AfterDeploymentTarget() // expected-error {{'AfterDeploymentTarget' is only available in macOS 11 or newer}} expected-note {{add 'if #available'}} |
1485 |
| - |
1486 |
| -if #available(macOS 11, *) { |
1487 |
| - _ = AfterDeploymentTarget() |
1488 |
| -} |
1489 |
| - |
|
0 commit comments