[Swift] Can't overload method and a function with the same name and different type signatures.

Originator:adam.kuipers
Number:rdar://23052929 Date Originated:9-Oct-2015
Status:DUPLICATE OF 17368791 Resolved:
Product:Developer Tools Product Version:Xcode 7.0.1 / Swift 2
Classification:Other Bug Reproducible:Always
 
Summary:
In Swift, if a method and a function share a name but have separate type signatures, the class of the method can't apply the global function.

See: attached playground or Swift file.

Steps to Reproduce:
All code in Swift. You can also see attached playground/Swift file.

1. Open a Swift file/playground.
2. Write a file level/global function.
3. Write a class with a method that shares a name with the aforementioned global function but has a separate type signature.
4. Use global function inside class.
5. Try to compile and despair.

Expected Results:
Code compiles, class is able to use global function normally.

Actual Results:
Code doesn't compile.

Version:
Xcode 7.0.1

Notes:
One can get around this by name mangling the global function herself. If you see the attached playground/file, that's what I did for the method `doBimpyWith2`. This isn't ideal for API's where the client can call on either global functions or methods as a shorthand.

Configuration:
Always occurs in Swift 2. Didn't try on Swift 1

Attachments:
'FunctionOverloadingBug.playground.zip' and 'FunctionOverloadingBug.swift' were successfully uploaded.

Comments

Apple Developer Relations

Engineering has determined that your bug report is a duplicate of another issue and will be closed. The open or closed status of the original bug report your issue was duplicated to appears in the yellow "Duplicate of XXXXXXXX" section of the bug reporter user interface. This section appears near the top of the right column's bug detail view just under the bug number, title, state, product and rank. If you have any questions or concerns, please update your report directly here: http://bugreport.apple.com/.

By adam.kuipers at Oct. 3, 2018, 9:57 p.m. (reply...)

Attached source code.

https://gist.github.com/adamkuipers/1126ad09a0478d64f069

By adam.kuipers at Oct. 9, 2015, 7:54 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!