mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Diagnose opaque types that depend on availability of a custom domain.
Serialization and IRGen don't yet support opaque return types that would depend on querying availability of a custom domain so we need to reject this code to avoid mis-compiling it.
This commit is contained in:
@@ -193,3 +193,19 @@ struct EnabledDomainAvailable {
|
||||
unavailableInDisabledDomain() // expected-error {{'unavailableInDisabledDomain()' is unavailable}}
|
||||
}
|
||||
}
|
||||
|
||||
protocol P { }
|
||||
|
||||
@available(EnabledDomain)
|
||||
struct AvailableInEnabledDomain: P { }
|
||||
|
||||
@available(EnabledDomain, unavailable)
|
||||
struct UnavailableInEnabledDomain: P { }
|
||||
|
||||
func testOpaqueReturnType() -> some P {
|
||||
if #available(EnabledDomain) { // expected-error {{opaque return type cannot depend on EnabledDomain availability}}
|
||||
return AvailableInEnabledDomain()
|
||||
} else {
|
||||
return UnavailableInEnabledDomain()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user