Swift Proposal: Module Selectors for Name Disambiguation
SE-0491 (via Becca Royal-Gordon):
We propose that Swift’s grammar be extended so that, wherever an identifier is written in source code to reference a declaration, it can be prefixed by
ModuleName::to disambiguate which module the declaration is expected to come from. This syntax will provide a way to resolve several types of name ambiguities and conflicts.[…]
That may sound like a farfetched edge case, but it’s surprisingly common for a module to contain a type with the same name. For instance, the
XCTestmodule includes anXCTestclass, which is a base class forXCTestCaseandXCTestSuite. To avoid this kind of trouble, developers must be careful to give modules different names from the types inside them—theObservationmodule, for example, might have been calledObservableif it didn’t have a type with that name.[…]
We could allow a special token, or no token, to be used in place of the module name to force a lookup to start at the top level, but not restrict it to a specific module.
[…]
There is currently no way to add a module selector to a use of a subscript.