Created
May 8, 2018 14:21
-
-
Save mikeash/46761b525de8a4c23e4a542585818c62 to your computer and use it in GitHub Desktop.
This file contains 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
class C {} | |
protocol P where Self: C { | |
var x: Int { get } | |
var y: Int { get } | |
} | |
extension P { | |
var x: Int { return 42 } | |
} | |
class D: C, P { | |
var y: Int { return x + 1 } | |
} | |
func f(vc: C) { | |
if let vc = vc as? P { | |
print(vc.x) | |
print(vc.y) | |
} | |
} | |
f(vc: D()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment