Repository: apple/swift
File: test/Interop/Cxx/modules/prevent-module-namespace-shadowed-by-namespace.swift (Swift)

Code before:
//--- shim.swift
// A shim around c2cxx that refers to a mixture of namespaced (C++) and
// top-level (C) decls; requires cxx-interoperability-mode
import c2cxx

//                          ,-namespace
//                         /
//                      vvvvv
public func shimId(_ n: c2cxx.number) -> c2cxx_number { return n }
// CHECK: public func shimId(_ n: c2cxx::c2cxx.c2cxx::number) -> c2cxx::c2cxx_number
//                                ^^^^^  ^^^^^ ^^^^^             ^^^^^
//                                   \      \     \                 \
//                                    `------\-----`-----------------`-module
//                                            `-namespace

//                                                            ,-namespace
//                                                           /
//                                                        vvvvv
@inlinable public func shimIdInline(_ n: c2cxx_number) -> c2cxx.number {
// CHECK:  public func shimIdInline(_ n: c2cxx::c2cxx_number) -> c2cxx::c2cxx.c2cxx::number
//                                       ^^^^^                   ^^^^^  ^^^^^ ^^^^^
//                                          \                       \      \     \
//                                           `-----------------------`------\-----`-module
//                                                                           `-namespace

// FIXME: Why isn't this printed with module selectors?
//                   ,-namespace
//                  /
//               vvvvv
          let m: c2cxx.number = n
// CHECK: let m: c2cxx.number = n
//               ^^^^^
//                  \
//                   `-namespace
          return m
}

//--- program.swift
// Uses the shim and causes it to be (re)built from its interface
import shim
func numberwang() { let _ = shimId(42) + shimIdInline(24) }


Review comment (refactor):
Just realized why: we're in an inlinable function body, so we're printing verbatim. I'll remove this comment.

Code after:
//--- shim.swift
// A shim around c2cxx that refers to a mixture of namespaced (C++) and
// top-level (C) decls; requires cxx-interoperability-mode
import c2cxx

//                          ,-namespace
//                         /
//                      vvvvv
public func shimId(_ n: c2cxx.number) -> c2cxx_number { return n }
// CHECK: public func shimId(_ n: c2cxx::c2cxx.c2cxx::number) -> c2cxx::c2cxx_number
//                                ^^^^^  ^^^^^ ^^^^^             ^^^^^
//                                   \      \     \                 \
//                                    `------\-----`-----------------`-module
//                                            `-namespace

//                                                            ,-namespace
//                                                           /
//                                                        vvvvv
@inlinable public func shimIdInline(_ n: c2cxx_number) -> c2cxx.number {
// CHECK:  public func shimIdInline(_ n: c2cxx::c2cxx_number) -> c2cxx::c2cxx.c2cxx::number
//                                       ^^^^^                   ^^^^^  ^^^^^ ^^^^^
//                                          \                       \      \     \
//                                           `-----------------------`------\-----`-module
//                                                                           `-namespace

// This declaration is printed verbatim because it's in an inlinable function
// body.
//                   ,-namespace
//                  /
//               vvvvv
          let m: c2cxx.number = n
// CHECK: let m: c2cxx.number = n
//               ^^^^^
//                  \
//                   `-namespace
          return m
}

//--- program.swift
// Uses the shim and causes it to be (re)built from its interface
import shim
func numberwang() { let _ = shimId(42) + shimIdInline(24) }