https://github.com/apple/swift/pull/26339 pulls namespaces in as enum decls. In https://github.com/apple/swift/pull/25870 @jrose proposes that there could be a dummy module where namespaces get put and then this can be found and other namespaces can be imported as extensions.
Because namespaces already have a notion of
getCanonicalDecl, this could be the one that is imported as the original namespace that other namespaces are an extension of.
Another option is to import all the namespace's redecls() as one decl. This works for unifying namespaces in a single file into a single swift namespace. However, if you "import module1"; use decl from namespace; import module2; use decl from namespace again. it appears that the namespace imported in module1 does not see the namespace redecl in module2, so it gets imported as the canonical decl without any reference to module2. The lazy decl loading would need to be aware that more decls could show up after the second import.
I think, however, that this all may break down when we have two swift modules that import c++ namespaces and then a third swift module that imports both of those. How would there be only one namespace-enum in that situation? Does it even matter that there is one namespace-enum in that case? Should namespace be private to the swift modules that imports them?