File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
test/Interop/SwiftToCxx/functions Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -661,6 +661,9 @@ class ModuleWriter {
661661 int result = getSortName (*rhs).compare (getSortName (*lhs));
662662 if (result != 0 )
663663 return result;
664+ // Two overloaded functions can have the same name when emitting C++.
665+ if (isa<AbstractFunctionDecl>(*rhs) && isa<AbstractFunctionDecl>(*lhs))
666+ return result;
664667
665668 // Prefer value decls to extensions.
666669 assert (!(isa<ValueDecl>(*lhs) && isa<ValueDecl>(*rhs)));
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h
3+ // RUN: %FileCheck %s < %t/functions.h
4+
5+ // RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
6+
7+
8+
9+ public func overloadedFunc( _ x: Int ) { }
10+ public func overloadedFunc( _ y: Float ) { }
11+
12+ public func overloadedFuncArgLabel( x _: Int ) { }
13+ public func overloadedFuncArgLabel( y _: Float ) { }
14+
15+ // CHECK-DAG: void overloadedFunc(float y) noexcept
16+ // CHECK-DAG: void overloadedFunc(swift::Int x) noexcept
17+ // CHECK-DAG: void overloadedFuncArgLabel(float _1) noexcept
18+ // CHECK-DAG: void overloadedFuncArgLabel(swift::Int _1) noexcept
You can’t perform that action at this time.
0 commit comments