Could not cast value of type 'A.B' to 'C.D'

Given:

So there is this main app repo XYZ where TargetA is a target which contains an enum EnumB.
Now there is another static library StaticLibC in a separate repository which contains a protocol ProtocolD.
EnumB conforms to ProtocolD.

When:

let abc: ProtocolD = EnumB.some(...)
The above line crashes with below error:
Could not cast value of type 'TargetA.EnumB' to 'StaticLibC.ProtocolD'
Can someone please help here ?