Skip to content

API Notes doesn't support renaming function overloads with different arities #83149

@maddyadams

Description

@maddyadams

Description

When using API Notes to rename C++ functions, if two functions are overloads with different arities (e.g. inline void foo() {} vs inline void foo(int x) {}), currently only one of them can be renamed. Renaming multiple results in an error about multiple function definitions

Reproduction

// Foo.hpp
inline void foo() {}
inline void foo(int x) {}
// module.modulemap
module CxxTarget {
    header "Foo.hpp"

    export *
}
// CxxTarget.apinotes
Name: CxxTarget
Functions:
- Name: foo
  SwiftName: bar()
- Name: foo
  SwiftName: bar(_:)
// main.swift
import CxxTarget

bar()
bar(4)
<unknown>:0: error: multiple definitions of global function 'foo'
/Users/maddyadams/Desktop/Xcode/APINotesOverloadRepro/Sources/APINotesOverloadRepro/main.swift:4:8: error: could not build Objective-C module 'CxxTarget'
import CxxTarget
       ^

Expected behavior

I expected the code would compile

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

rdar://150551624

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions