mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
C++ namespaces are module-independent, but enums are owned by their module's in Swift. So, to prevent declaring two enums with the same name, this patch implements a new approach to namespaces: enums with extensions.
Here's an example:
```
// Module A
namespace N { void test1(); }
// Module B
namespace N { void test2(); }
// __ObjC module
enum N { }
// Swift module A
extension N { func test1() }
// Swift module B
extension N { func test1() }
```
Thanks to @gribozavr for the great idea.
13 lines
373 B
C
13 lines
373 B
C
#ifndef TEST_INTEROP_CXX_NAMESPACE_INPUTS_CLASSES_SECOND_HEADER_H
|
|
#define TEST_INTEROP_CXX_NAMESPACE_INPUTS_CLASSES_SECOND_HEADER_H
|
|
|
|
#include "classes.h"
|
|
|
|
struct ClassesNS1::ClassesNS2::DefinedInDefs {
|
|
const char *basicMember() {
|
|
return "ClassesNS1::ClassesNS2::DefinedInDefs::basicMember";
|
|
}
|
|
};
|
|
|
|
#endif // TEST_INTEROP_CXX_NAMESPACE_INPUTS_CLASSES_SECOND_HEADER_H
|