-
Notifications
You must be signed in to change notification settings - Fork 10.5k
AST: Add new implementation of getOpenedExistentialSignature() #76206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AST: Add new implementation of getOpenedExistentialSignature() #76206
Conversation
This will replace all existing usages of the old implementation.
…dExistentialTypeShape()
…straintsWithExistentialBase()
…veUnfulfillableConstraintsWithExistentialBase()
df4af5b
to
56a279a
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
56a279a
to
369a57e
Compare
369a57e
to
39d77b8
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
// Specifically ignore parameterized protocols and existential | ||
// metatypes because we can erase them to the upper bound. | ||
if (type->is<ParameterizedProtocolType>() || | ||
type->is<ExistentialMetatypeType>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slavapestov I think we need to be more careful with this sort of loosening. The more sophisticated erasure we support, the harder it will be for everyone to get off of it once we come up with something better. The non-metatype case was never supported, so I think the same should hold for an existential metatype:
class C<T> {}
protocol P {
associatedtype A
func f() -> any P & C<A>
func fMeta() -> any (P & C<A>).Type
}
do {
let p: any P
let _ = p.f() // error
let _ = p.fMeta() // crash
}
The call to fMeta()
used to miscompile and now crashes, so we can still make it an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new mechanism allows type variables to appear in the existential type. It will eventually replace the old variant that takes a parent generic signature.