Avatar
norio_nomura 4/21/2017 1:52 AM
Swift 4.0のCHANGELOGにこんなのが https://github.com/apple/swift/blob/master/CHANGELOG.md
SR-1529: Covariant method overrides are now fully supported, fixing many crashes and compile-time assertions when defining or calling such methods. Examples:
class Bed {} class Nook : Bed {} class Cat<T> { func eat(snack: T) {} func play(game: String) {} func sleep(where: Nook) {} } class Dog : Cat<(Int, Int)> { // 'T' becomes concrete override func eat(snack: (Int, Int)) {} // 'game' becomes optional override func play(game: String?) {} // 'where' becomes a superclass override func sleep(where: Bed) {} }
(edited)
swift - The Swift Programming Language