Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Last active April 1, 2017 14:27
Show Gist options
  • Save mbrandonw/5e4f475c4e0e2caa1ce38c44531faf46 to your computer and use it in GitHub Desktop.
Save mbrandonw/5e4f475c4e0e2caa1ce38c44531faf46 to your computer and use it in GitHub Desktop.
Swift bug with extending generic typealiases?
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
}
}
@mbrandonw
Copy link
Author

Update: this is not a swift compiler bug, just an unimplemented part of generic typealiases: https://twitter.com/dgregor79/status/847975206538813440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment