File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
test/Interop/SwiftToCxx/functions Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -669,6 +669,13 @@ class ModuleWriter {
669669 // Two overloaded functions can have the same name when emitting C++.
670670 if (isa<AbstractFunctionDecl>(*rhs) && isa<AbstractFunctionDecl>(*lhs))
671671 return result;
672+ // A function and a global variable can have the same name in C++,
673+ // even when the variable might not actually be emitted by the emitter.
674+ // In that case, order the function before the variable.
675+ if (isa<AbstractFunctionDecl>(*rhs) && isa<VarDecl>(*lhs))
676+ return 1 ;
677+ if (isa<AbstractFunctionDecl>(*lhs) && isa<VarDecl>(*rhs))
678+ return -1 ;
672679
673680 // Prefer value decls to extensions.
674681 assert (!(isa<ValueDecl>(*lhs) && isa<ValueDecl>(*rhs)));
Original file line number Diff line number Diff line change @@ -48,3 +48,8 @@ public func passVoidReturnVoid() { print("passVoidReturnVoid") }
4848// CHECK: SWIFT_INLINE_THUNK void passVoidReturnVoid() noexcept SWIFT_SYMBOL("s:9Functions014passVoidReturnC0yyF") {
4949// CHECK: return _impl::$s9Functions014passVoidReturnC0yyF();
5050// CHECK: }
51+
52+ // CHECK: SWIFT_INLINE_THUNK void varFunctionSameName
53+ public func varFunctionSameName( _ x: CInt ) { }
54+
55+ public var varFunctionSameName : CInt = 0
You can’t perform that action at this time.
0 commit comments