xcode - Redundant conformance error message Swift 2 -


i updated project swift 2, , received bunch of redundant conformance of xxx protocol yyy. happens (or always) when class conforms customstringconvertible. place equatable.

class graphfeaturenumbersetrange: graphfeature, customstringconvertible { // <--- error here ... } 

i suspect don't need explicitly conform protocol when implement var description: string { }, or whatever methods protocol requires. should follow fixit instructions , remove these? swift automatically infer conformance if class implements protocol's methods?

you'll error message in xcode 7 (swift 2) if subclass declares conformance protocol inherited superclass. example:

class myclass : customstringconvertible {     var description: string { return "myclass" } }  class subclass : myclass, customstringconvertible {     override var description: string { return "subclass" } } 

the error log shows:

 main.swift:10:27: error: redundant conformance of 'subclass' protocol 'customstringconvertible' class subclass : myclass, customstringconvertible {                           ^ main.swift:10:7: note: 'subclass' inherits conformance protocol 'customstringconvertible' superclass here class subclass : myclass, customstringconvertible {       ^ 

removing protocol conformance subclass declaration solves problem:

class subclass : myclass {     override var description: string { return "subclass" } } 

but superclass must declare conformance explicitly, not automatically inferred existence of description property.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -