-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] add missing Element
type witnesses
#70142
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
With `NoncopyableGenerics` enabled, we currently lose some ability for associatedtype inference to find a suitable type witness based on a value witness. (rdar://118998138) The stdlib accidentally uses that inference for Sequence.Element, due to the default witness for `_customContainsEquatableElement` mentioning `Iterator.Element` whereas the requirement only states `Element`.
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.
Good find, thanks!
@swift-ci please test |
I'm fine with making these typealiases present even when NoncopyableGenerics is disabled. It should be a non-functional change. |
Can we revert this after fixing rdar://118998138? Doesn't this mean in its present state, NoncopyableGenerics could break non-stdlib code that hits this bug too? |
@swift-ci please test macOS platform |
Yes, once that associatedtype inference issue is resolved, in theory we can revert this patch. But @glessard and others have expressed a desire to make these typealiases explicit anyway, so they're going to end up becoming non-conditional in another PR. I'm just adding these in now since I'm going to rely on them soon.
Yes. Until rdar://118998138 is fixed non-stdlib code relying on that inference is broken. |
I think there's a good argument that this should not require an explicit type witness: protocol P {
associatedtype A: Q
associatedtype B where B == A.B
}
protocol Q {
associatedtype B
}
struct S: P {
struct A: Q {
typealias B = Int
}
// should not be needed:
// typealias B = Int
} |
It's fine to not require them, but the standard library can stand to be as explicit as possible. |
With
NoncopyableGenerics
enabled, we currently lose some ability for associatedtype inference to find a suitable type witness based on a value witness. (rdar://118998138)The stdlib accidentally uses that inference for Sequence.Element, due to the default witness for
_customContainsEquatableElement
mentioningIterator.Element
whereas the requirement only statesElement
.