-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Provide an explicit iterator for SyntaxCollection #13112
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
The default IndexingIterator for a custom collection is not suitable for subclasses that specialize the element type the way libSyntax does. Overriding it with a more specific iterator, even with something like covariant overrides, would not work because it the iterator is generic over its base collection, not its element type. Provide a custom iterator parameterized by the element type instead.
@swift-ci please smoke test |
I wouldn't say this is NFC, because it changes what the iterator type is, no? Regardless, this is how this was intended to work. LGTM. |
Before this patch, iterating over the syntax collection in a for-each loop wasn't possible. The only way clients would break is if they were relying on the default iterator type specifically being IndexingIterator. |
Right, yes. But adding that functionality makes this an FC. 😉 |
Eh, I'm not willing to die on this hill. |
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.
LGTM!
CI Passed, I say merge. ⛴ |
The default IndexingIterator for a custom collection is not suitable for subclasses that specialize the element type the way libSyntax does. Overriding it with a more specific iterator, even with something like covariant overrides, would not work because it the iterator is generic over its base collection, not its element type. Provide a custom iterator parameterized by the element type instead.
The default IndexingIterator for a custom collection is not suitable for
subclasses that specialize the element type the way libSyntax does.
Overriding it with a more specific iterator, even with something like
covariant overrides, would not work because it the iterator is generic
over its base collection, not its element type.
Provide a custom iterator parameterized by the element type instead.
We discovered this while working with the libSyntax representation in Silt.