mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Now that most of the compiler tracks availability in terms of AvailabilityDomain, it's time to do so in AvailabilityContext as well. This will ensure that the compiler accurately suppresses diagnostics about a decl being unavailable in an arbitrary domain when the context of the use is already unavailable in that domain. With this change, most of the special-casing for the Embedded Swift availability domain has been removed from the compiler, outside of parsing and interface printing.
69 lines
2.9 KiB
Swift
69 lines
2.9 KiB
Swift
// RUN: %target-typecheck-verify-swift -parse-stdlib -enable-experimental-feature Embedded
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
@_unavailableInEmbedded
|
|
public struct UnavailableInEmbedded {}
|
|
// expected-note@-1 {{'UnavailableInEmbedded' has been explicitly marked unavailable here}}
|
|
|
|
@available(*, unavailable, message: "always unavailable")
|
|
public struct UniverallyUnavailable {}
|
|
// expected-note@-1 {{'UniverallyUnavailable' has been explicitly marked unavailable here}}
|
|
|
|
@_unavailableInEmbedded
|
|
public func unavailable_in_embedded() { }
|
|
// expected-note@-1 {{'unavailable_in_embedded()' has been explicitly marked unavailable here}}
|
|
|
|
@available(*, unavailable, message: "always unavailable")
|
|
public func universally_unavailable() { }
|
|
// expected-note@-1 3 {{'universally_unavailable()' has been explicitly marked unavailable here}}
|
|
|
|
@_unavailableInEmbedded
|
|
public func unused() { } // no error
|
|
|
|
public struct S1 {} // expected-note 2 {{found this candidate}}
|
|
public struct S2 {} // expected-note 2 {{found this candidate}}
|
|
|
|
@_unavailableInEmbedded
|
|
public func has_unavailable_in_embedded_overload(_ s1: S1) { }
|
|
|
|
public func has_unavailable_in_embedded_overload(_ s2: S2) { }
|
|
|
|
@available(*, unavailable)
|
|
public func has_universally_unavailable_overload(_ s1: S1) { }
|
|
|
|
public func has_universally_unavailable_overload(_ s2: S2) { }
|
|
|
|
public func available(
|
|
_ uie: UnavailableInEmbedded, // expected-error {{'UnavailableInEmbedded' is unavailable: unavailable in embedded Swift}}
|
|
_ uu: UniverallyUnavailable // expected-error {{'UniverallyUnavailable' is unavailable: always unavailable}}
|
|
) {
|
|
unavailable_in_embedded() // expected-error {{'unavailable_in_embedded()' is unavailable: unavailable in embedded Swift}}
|
|
universally_unavailable() // expected-error {{'universally_unavailable()' is unavailable: always unavailable}}
|
|
has_unavailable_in_embedded_overload(.init())
|
|
has_universally_unavailable_overload(.init()) // not ambiguous, selects available overload
|
|
}
|
|
|
|
@_unavailableInEmbedded
|
|
public func also_unavailable_in_embedded(
|
|
_ uie: UnavailableInEmbedded, // OK
|
|
_ uu: UniverallyUnavailable // OK
|
|
) {
|
|
unavailable_in_embedded() // OK
|
|
universally_unavailable() // expected-error {{'universally_unavailable()' is unavailable: always unavailable}}
|
|
has_unavailable_in_embedded_overload(.init()) // expected-error {{ambiguous use of 'init()'}}
|
|
has_universally_unavailable_overload(.init()) // not ambiguous, selects available overload
|
|
}
|
|
|
|
@available(*, unavailable)
|
|
public func also_universally_unavailable(
|
|
_ uie: UnavailableInEmbedded, // OK
|
|
_ uu: UniverallyUnavailable // OK
|
|
) {
|
|
unavailable_in_embedded()
|
|
universally_unavailable() // expected-error {{'universally_unavailable()' is unavailable: always unavailable}}
|
|
has_unavailable_in_embedded_overload(.init()) // expected-error {{ambiguous use of 'init()'}}
|
|
has_universally_unavailable_overload(.init()) // not ambiguous, selects available overload
|
|
}
|