Swift XCTest namespace issue

Originator:matteosartori
Number:rdar://21034696 Date Originated:20-May-2015 10:24 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.4 (6E23)
Classification:Security Reproducible:Always
 
Summary:
I have a .swift file with a public function `encode` that takes a few parameters. I also have an XCTest file to test the `encode` function.
The XCTest file imports my code fine – I'm able to call public functions from it and even the function that is causing me trouble, encode, is autocompleting just fine when I start writing it out. However, when I try to compile it, I can see that it fails (with "Extra argument in call") because the compiler thinks I'm calling Foundation.encode rather than my own.

Changing the name of it makes it work fine, but that is beside the point which is this; Swift is supposed to prioritise your module over the system's

Steps to Reproduce:
Add a public function named encode(a: Int, b: Int). 
In the XCTestCase file for the project import your module and in the class' test function call your encode function.

Expected Results:
That the encode function defined in my imported module is called.

Actual Results:
Fails compilation with the error "Extra argument in call".

Regression:
If I rename the encode function to some other non-conflicting name it works.

Comments

A dummy project that demonstrates the issue here

By matteosartori at May 23, 2015, 9:52 a.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!