I'm transitioning an iOS app I'm working on to use protocols instead of hard coding classes, and I'm trying to not name the protocols XxxProtocol
. For most of my changes this hasn't been a problem, however I ran into an issue when the name of the module I import is the same as the class it exports and what I want to shadow.
For example if there is a module named Useful
and I want to create a protocol named Useful
in MyModule
and conform the class Useful.Useful
to it I get an error.
import Useful
protocol Useful {
// ...requirements here...
}
extension Useful.Useful: MyModule.Useful { // Error: 'SomeClass' is not a member type of protocol 'MyModule.Useful'
}
I know there is a difference between the module Useful
and the class MyModule.Useful
, however I don't know how to tell the compiler to use the module and not the class when I'm inside MyModule
.
I have a feeling that this is a case where I need to just go with UsefulProtocol
, however I was wondering if there was a way to work around this and/or if this is expected.