-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Explicit stricter minimization of protocol composition types for redeclaration checking #39694
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
Conversation
@swift-ci please smoke test |
552e053
to
21f6be9
Compare
@swift-ci please smoke test macOS |
21f6be9
to
ee49577
Compare
@swift-ci please smoke test macOS |
ee49577
to
78c939f
Compare
@swift-ci please smoke test macOS |
78c939f
to
0704e90
Compare
@swift-ci please smoke test macOS |
@swift-ci please test source compatibility debug |
0704e90
to
4602bf1
Compare
@swift-ci please smoke test macOS |
Is this also ABI-breaking potentially, if you previously had a redundant AnyObject constraint in a composition that is now minimized away? |
Yes. Does a smoke test not exclude any mangling differences? |
It's pretty unlikely that someone has a binary framework that relies on this, but it might be safer if minimization was an explicit step and not part of getCanonicalType()? |
You mean, to minimize selectively instead of having canonical types be truly minimal? |
Yeah. I'm assuming this is for the type erasure when you use an existential member that returns an associated type -- you could minimize inside the member access path when computing the erased type of the member. |
Not anymore. That was the original plan, but it looks like using canonical types is enough to make the erasure work (we never retain sugar in generic signatures anyway, so there's no reason to separate minimization from canonicalization in this particular case). If the ABI break is a concern, we can drop that part of the code and still benefit from the absence of "premature canonicalization". |
@slavapestov What if we special-case protocol composition types in |
I'd prefer not to add any special cases and avoid changing getCanonicalType() to minimize protocol compositions. If you need to minimize protocol compositions for something, you can add a new method to ProtocolCompositionType (or ExistentialLayout or whatever) which performs it explicitly. |
To be clear, are we ready to take on the source break if I make stricter minimization explicit and use it in redeclaration checking, as well as the other part of this PR (4602bf1)? |
4602bf1
to
504b8be
Compare
@swift-ci please smoke test macOS |
504b8be
to
3ebb095
Compare
@swift-ci please smoke test macOS |
…r and no layout constraint
3ebb095
to
6b58266
Compare
@swift-ci please smoke test |
6b58266
to
d2373e7
Compare
@slavapestov Could I ask for another opinion on this? I kept it narrow as per your suggestion. |
lib/AST/Type.cpp
Outdated
{Requirement(RequirementKind::Conformance, GParam, CanTy)}); | ||
if (!Sig) { | ||
return CanTy; | ||
} |
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.
Cool! Can this use ASTContext::getOpenedArchetypeSignature()?
…r redeclaration checking
d2373e7
to
4b1424e
Compare
@swift-ci please smoke test |
@swift-ci please test source compatibility |
@slavapestov Much obliged |
Enable explicit stronger minimization of protocol compositions via generic signature computation for purposes like redeclaration checking.
Note: This is a source-breaking change, because the following is now a redeclaration error: