Xcode 7.1b1: [Swift] Compiler does not accept SequenceType conformance for type conforming to protocol that descends from SequenceType when using a generic generator
| Originator: | janoschhildebrand | ||
| Number: | rdar://22720512 | Date Originated: | 16-Sep-2015 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 7.1b1 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
The following code snippet fails to compile with the compiler complaining that 'Test' does not conform to SequenceType.
If a non-generic generator that wraps 'Test' instead of a generic 'TestType' is used, this compiles successfully.
This also compiles if 'TestType' does not require SequenceType conformance.
An example project is attached.
struct Test : TestType {
var storage: [Int] = []
mutating func pop() -> Int? {
return storage.popLast()
}
}
extension Test : SequenceType {
func generate() -> TestGenerator<Test> {
return TestGenerator(self)
}
}
public protocol TestType : SequenceType {
mutating func pop() -> Int?
}
struct TestGenerator<T : TestType> : GeneratorType {
private var content: T
init(_ content: T) {
self.content = content
}
mutating func next() -> Int? {
return content.pop()
}
}
Steps to Reproduce:
1) Open the attached project
2) Build
Expected Results:
The given code should compile successfully.
Actual Results:
Compilation fails with: "Type 'Test' does not conform to protocol 'SequenceType'".
Version:
OS X 10.11 (15A282b)
Version 7.1 beta (7B60)
Apple Swift version 2.0 (swiftlang_PONDEROSA-700.1.100.2 clang-700.1.74)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!