Last active
October 6, 2017 08:02
-
-
Save slavapestov/f455c6184b402f3ffc656f904f1e5d59 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
// Example 1 | |
protocol P { | |
func f() -> Self | |
} | |
extension P { | |
func f() -> Self { | |
return self | |
} | |
} | |
class C : P {} | |
// Example 2 | |
protocol Q { | |
associatedtype I = Self | |
func f() -> I | |
} | |
extension Q where Self.I == Self { | |
func f() -> Self { | |
return self | |
} | |
} | |
class D : Q {} | |
// Example 1 fails to type check in Swift 4.0. | |
// Example 2 works in Swift 4.0, but this doesn't work, which is counter-intuitive because E should inherit all members of D: | |
class E : D {} | |
E().f() | |
// b.swift:19:5: error: 'E' is not convertible to 'D' | |
// E().f() | |
// ~~~~^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment