swift
d0c40c0a - Diagnose Availability for Parameterized Existential Types

Commit
3 years ago
Diagnose Availability for Parameterized Existential Types Usages of parameterized existential types that involve runtime type metadata to resolve must be gated on the appropriate OS version in which those features have landed. This means the following usage classes must appear gated: - Checked casts (is, as?, as!) - As arguments to generic types (Foo<any P<T>>) - As type witnesses to protocol conformances - In erasure expressions (and optional-to-any erasure expressions) - In metatypes - Tuples What does this leave? - Concrete usages - any P<T> as a parameter or result type - Any amount of optional types around existential types - Static casts (as) It's worth calling out the fact that usages of parameterized existential types in tuples are banned but usages in struct members are not. This is due to the fact that Tuple identity and runtime layout is determined by a metadata query against each component type. Whereas for a struct, the opaque type layout does not depend upon the type metadata of the fields at runtime, and the identity of the struct is determined nominally rather than structurally. Practically, this means that one can work around the lack of tuples by defining a struct with an equivalent type structure as fields: struct AdHocEraser { var x: any P<T> } rdar://92197245
Author
Committer
Parents
Loading