Protocol Type does not conform to Protocol
| Originator: | GriotSpeak | ||
| Number: | rdar://21432282 | Date Originated: | 17-Jun-2015 04:42 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A120f) |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
Attempting to specialize a generic type where a parameter T is constrained to protocol MyProtocol fails when passing in MyProtocol as the Type satisfying the constraint.
Steps to Reproduce:
protocol MyType {
}
struct Thing : MyType {
}
struct Foo<T, U : MyType> {
let one:T
let two:U
}
struct Bar<T> {
let one:T
let two:MyType
}
let theThing = Thing()
let expected: Foo<Int, Thing> = Foo(one: 0, two: theThing)
let nice:Bar<Int> = Bar(one: 1, two: theThing)
// I think it could be great if the following line were basically equivalent to the line immediately above.
let potentiallyGreat: Foo<Int, MyType> = Foo(one: 2, two: theThing)
Expected Results:
The last line, `let potentiallyGreat: Foo<Int, MyType> = Foo(one: 2, two: theThing)`, should compile and be equivalent to `let nice:Bar<Int> = Bar(one: 1, two: theThing)`
Actual Results:
Compilation fails “Generic parameter ‘U’ cannot be bound to non-@objc protocol type ‘MyType’”
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!