Created
June 15, 2017 03:23
-
-
Save pcantrell/0c2f27defd23f80f26d7bb1cf2cc9694 to your computer and use it in GitHub Desktop.
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
protocol A { | |
func foo() | |
} | |
extension A { | |
func foo() { print("A foo") } | |
func bar() { print("A bar") } | |
} | |
protocol B: A { | |
func bar() | |
} | |
extension B { | |
func foo() { print("B foo") } | |
func bar() { print("B bar") } | |
} | |
class C: B { } | |
let c: B = C() | |
print("Static type B:") | |
c.foo() // prints "B foo" | |
c.bar() // prints "B bar" | |
print("Static type A:") | |
(c as A).foo() // prints "B foo" | |
(c as A).bar() // prints "A bar" !! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment