Created
June 1, 2017 15:07
-
-
Save ezura/dbb249c5663e97985f49483e6bbac2e5 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 Permission {} | |
| enum Default: Permission {} | |
| enum Strict: Permission {} | |
| protocol P { | |
| associatedtype PermissionMode: Permission = Default | |
| func f() -> String | |
| } | |
| extension P { | |
| func callF() -> String { | |
| return "default " + #function + " - " + f() | |
| } | |
| func f() -> String { | |
| return "default " + #function + " - " + v | |
| } | |
| var v: String { return "default " + #function } | |
| } | |
| extension P where Self.PermissionMode == Strict { | |
| func f() -> String { | |
| return "Self.PermissionMode == Strict " + #function + " - " + v | |
| } | |
| } | |
| struct A: P {} | |
| struct B: P { | |
| typealias PermissionMode = Strict | |
| } | |
| A().callF() // "default callF() - default f() - default v" | |
| B().callF() // "default callF() - Self.PermissionMode == Strict f() - default v" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment