Last active
April 1, 2017 14:27
-
-
Save mbrandonw/5e4f475c4e0e2caa1ce38c44531faf46 to your computer and use it in GitHub Desktop.
Swift bug with extending generic typealiases?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct F<A, B> { | |
let f: (A) -> B | |
} | |
typealias G<A> = F<A, Int> | |
extension G { | |
func something(a: A) -> Int { | |
return self.f(a) | |
// ^--- error: cannot convert return expression of type 'B' to return type 'Int' | |
} | |
} | |
extension F where B == Int { | |
func somethingElse(a: A) -> Int { | |
return self.f(a) | |
// ^--- this works | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update: this is not a swift compiler bug, just an unimplemented part of generic typealiases: https://twitter.com/dgregor79/status/847975206538813440