Multiple protocol conformance build error workaround?

Hello,


I'm getting a build error and wonder if there is a way to get multiple protocol conformance working.


protocol ProtocolA {}
protocol ProtocolB {}

protocol Protocol1 {
     var manager: ProtocolA?
}


protocol Protocol2 {
     var manager: ProtocolB?
}


class Implementation: Protocol1, Protocol2 {
     var manager: protocol<ProtocolA, ProtocolB>?
}


I get the following errors:
error: type 'Implementation' does not conform to protocol 'Protocol1'

error: type 'Implementation' does not conform to protocol 'Protocol2'

note: candidate has non-matching type '(ProtocolA & ProtocolB)?'


I would have thought that the compiler would have allowed Implementation's manager to conform to both protocols.


Any ideas on how to get something like this working?

You want Implementation to conform to Protocol1. That means that this code should be valid:


class Foo: ProtocolA {}
var proto1instance = Implementation() as Protocol1
proto1instance.manager = Foo()


Since proto1instance is Protocol1, the compiler has no way of knowing that manager should also conform to ProtocolB.


But your code presumes that the compiler knows this. "class Implementation: Protocol1, Protocol2" means that the class should be able to appear as either Prococol1 and Protocol2, independently.

Multiple protocol conformance build error workaround?
 
 
Q