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
[SR-7911] FlattenSequence.Iterator no longer conforms to Sequence #50446
Comments
In 4.1, Offhand I don't know if that's a result of a standard library change or a something that happens differently during expression type checking. |
Isn't `FlattenIterator<LazyMapIterator<IndexingIterator<Array<Foo>>, [Bar]>>` the desugared form of `FlattenSequence<LazyMapCollection<[Foo], [Bar]>>.Iterator`? In 4.2 we made type alias types preserve sugar in more cases. However this should not have changed behavior. |
Actually I'm wrong, `FlattenSequence.Iterator` is now a bona-fide struct. |
Ok I see. In 4.1, FlattenIterator conformed to Sequence too. We have a default implementation of Sequence for Self : IteratorProtocol where makeIterator() just returns self. Adding this conformance to the original code example makes it compile:
However I think it makes more sense to change the last two lines to:
That is, just dropping the makeIterator() call. @airspeedswift do you want to add the "FlattenSequence.Iterator : Sequence" conformance, or just close this as working as expected? |
@slavapestov Thanks for the 1st workaround. I don't use the 2nd because I iterate barIterator using next() and stops when some condition is met and append the rest to bars. I can, by manually keeping track of indices(I'm actually iterating 2 such iterators, I'm doing merging), but I think the iterator version is more elegant. @airspeedswift I think Sequence.Iterator should be a sequence. |
@slavapestov I have issues with the 1st workaround: since #if swift(>=4.2) tests language version instead of compiler version, how can I make my project compilable in both Xcode 9.4 and Xcode 10? |
@swift-ci create |
Environment
Xcode 10 beta 1
Additional Detail from JIRA
md5: 0b5674778a68e9f7a21ddc511b8b30ad
Issue Description:
It seems Swift 4.2 compiler doesn't think FlattenSequence<LazyMapCollection<[Foo], [Bar]>>.Iterator is a Sequence of Bar. It's a regression, it worked in Swift 4.1.
The text was updated successfully, but these errors were encountered: