Last active
April 1, 2017 20:33
-
-
Save irace/a06a9de2ffe10821e91936d763d3f6cf to your computer and use it in GitHub Desktop.
Protocol inheritance and associated type specification
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
/* | |
This Swift bug seems to be related: https://bugs.swift.org/browse/SR-2235. Seems as though | |
the different ways that worked previously might have never actually been intended? | |
*/ | |
protocol DataVendor { | |
associatedtype Vended | |
var data: [Vended] | |
func data(at index: Int) -> Vended | |
} | |
// This worked in Swift 3.0 | |
protocol StringVendor: DataVendor { | |
typealias Vended = String | |
} | |
// This now seems to be required, as of Swift 3.1 | |
protocol StringVendor: DataVendor { | |
var data: [String] | |
func data(at index: Int) -> String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment