Swift - same name for class and namespace

Good day!


I have a problem with swift.


In my project I have class, for example State.

Now I want to import framework, for example Framework and it has class named Framework and public enum State. State is not nested in Framework class.


When I try to use it with


Framework.State


compiler tries to find State enum nested in class Framework, not in namespace Framework


How can I deal with this problem?


Thank you

Replies

Did you try just using it as "State", without the module prefix? If that conflicts with a State in another module, then I'd strongly recommend you change yours to something else, because "state" is too generic a word to be polluting any global(-ish) namespace. You can't fix the other misuse, but you can fix yours.


Or, as a workaround, move the enum definition inside class Framework. Then "Framework.State" will be the normal way of referencing it.


Or, adopt a policy of not naming classes the same as their module.


However, youy should file a bug against Swift, because there ought to be a way of specifying your enum unambiguously.

I have filed a bug: https://bugs.swift.org/browse/SR-5304