[SR-1863] for loop produces compiler error if the base class of the instance conforms to Collection protocol #44472
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Environment
Xcode Version 8.0 Beta
Additional Detail from JIRA
md5: 7929fc5fb48ff92511ff43aa4c401f7a
Issue Description:
I have a class that conforms to the Collection protocol, with some other classes inheriting from it.
But when I try to use for loop on instances of the derived classes, the Swift compiler complains:
`'IndexingIterator<DerivedCustomCollection>' is not convertible to 'Iterator' (aka 'IndexingIterator<CustomCollection>')`
Then I figured out that specifying the Iterator type alias will resolve the problem, but then another problem emerged: I cannot use for loop on the enumerated() if I do this..
I have put the code to reproduce this bug into a gist:
https://gist.github.com/cezheng/59c90a48fa13782482fe95fe87bb6339
Just copy the code into an Xcode 8 playground and you will immediately see the problem.
Thanks🙂
The text was updated successfully, but these errors were encountered: