Created
December 24, 2020 15:19
-
-
Save danylokos/0f5498a3d0ee0034aa836017fe7d20c3 to your computer and use it in GitHub Desktop.
swift multi protocol error
This file contains 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
/* | |
compilation error: | |
Type 'StructC' does not conform to protocol 'ProtoA' | |
Type 'StructC' does not conform to protocol 'ProtoB' | |
*/ | |
protocol ProtoAInput { | |
func funcA() | |
} | |
protocol ProtoA { | |
var input: ProtoAInput { get } | |
} | |
protocol ProtoBInput { | |
func funcB() | |
} | |
protocol ProtoB { | |
var input: ProtoBInput { get } | |
} | |
struct StructC: ProtoA, ProtoB { | |
var input: ProtoAInput & ProtoBInput { return self } | |
} | |
extension StructC: ProtoAInput { | |
func funcA() { print("funcA") } | |
} | |
extension StructC: ProtoBInput { | |
func funcB() { print("funcB") } | |
} | |
let s = StructC() | |
s.funcA() | |
s.funcB() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment