Swift 1 & 2: Default Parameter Values Aren't Visible to API Consumers

Originator:paul
Number:rdar://21505010 Date Originated:23-Jun-2015 12:34 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Swift 1 & 2
Classification:Enhancement Reproducible:Always
 
Summary:
Swift allows developers to provide default values for functions. So I could, for example write the following code:

func test(arg1: Int, arg2: Int = 5) {
  print("\(arg + arg2)”)
}

test(1) // prints 6
test(1, 7) // prints 8

However, in autocomplete for this function, I never get an entry for the convenience case (i.e., test(arg1:)). This problem is even worse when writing Objective-C code because the auto generated compatibility header does not include the convenience case.

Steps to Reproduce:
1. Write a swift function that defines default parameter values.

Expected Results:
These default parameter values would be valuable to consumers of my API.

Actual Results:
The default parameter values are very undiscoverable.

Comments


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!