Swift 2: Protocol extension methods cannot be partially applied, full stop?
| Originator: | rix.rob | ||
| Number: | rdar://21289579 | Date Originated: | 08-Jun-2015 05:46 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-7-beta (7A120f) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
SequenceType has Problems with partial application (rdar://21289273) so let’s take it out of the equation.
Steps to Reproduce:
1. Write this code:
protocol P {
func f(x: Int) -> Int
}
extension P {
func f(x: Int) -> Int { return x }
}
struct S: P {}
let f: P.f
let g: S -> Int -> Int = P.f
Expected Results:
Like before, f is wishful thinking.
g should compile tho.
Actual Results:
./partial.swift:14:10: error: 'f' is not a member type of 'P'
let g: P.f
~ ^
./partial.swift:15:28: error: could not find an overload for 'f' that accepts the supplied arguments
let f: S -> Int -> Int = P.f
~~^
Regression:
If these were free functions we could partially apply them, but nooooo.
Notes:
N/A
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!
Can't try this out in Xcode right now, but wouldn't P.f be a P -> Int -> Int, not an S -> Int -> Int? (Of course, it could still take an argument of type S, but also of other types.)
And what are you trying to do with Let f: P.f? P.f isn't a type -- you shouldn't be able to use it as a type annotation. Or am I missing something?
Either way, I definitely agree that (for consistency with instance methods) you should be able to refer to P.f and get out a function!