Last active
June 28, 2017 18:45
-
-
Save lukeredpath/7b3503a838444f5eaab38afbd61d6947 to your computer and use it in GitHub Desktop.
Swift typealias problem
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 SomeProtocol { | |
typealias SomeType = String | |
} | |
class SomeClass: SomeProtocol { | |
let something: SomeType | |
} | |
// Compiles in Swift 3.1 | |
// Compile error in Swift 3.0.2: "Use of undeclared type SomeType" | |
// The same problem exists with associated types: | |
protocol HasAssociatedType { | |
associatedtype CustomType | |
var something: CustomType { get } | |
} | |
class ImplementsAssociatedType: HasAssociatedType { | |
var something: String? // infers CustomType = String? | |
var somethingElse: CustomType { // Error: "Use of undeclared type CustomType" | |
return something | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment