Skip to content

Instantly share code, notes, and snippets.

@bkase
Created January 5, 2018 05:56
Show Gist options
  • Save bkase/584d56866beaa558aa2d590dcc5a9091 to your computer and use it in GitHub Desktop.
Save bkase/584d56866beaa558aa2d590dcc5a9091 to your computer and use it in GitHub Desktop.
Fun with extension-method-return-type overriding (port from Swift Sandbox)
protocol Base { }
extension Base {
var a: String? { return nil }
var b: Int? { return nil }
}
protocol A: Base {
var a: String { get }
}
protocol B: Base {
var b: Int { get }
}
protocol All: A, B { }
struct Frag: B {
let b: Int
}
print(Frag(b: 3).a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment