Last active
June 16, 2017 18:58
-
-
Save pcantrell/7d1913585d1f7fc3f578aed7ea68cc8f 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
public protocol P { | |
func foo() | |
} | |
public protocol Q: P { | |
} | |
extension Q { | |
final func foo() { … } | |
} | |
class Thingy: P { | |
func foo() { … } // OK! | |
} | |
class Dingy: Q { | |
func foo() { … } // Not allowed, because final | |
} | |
let p: P = … | |
p.foo() // Needs dynamic dispatch, because P is public & other module could provide other impl | |
let q: Q = … | |
q.foo() // Can use static dispatch iff extensions allow final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment