Swift+UIKit: UIStackView.insertArrangedSubview(_:at:) Index Parameter Type Is Inconsistent

Originator:wetzeal
Number:rdar://28059603 Date Originated:8/29/2016
Status:Open Resolved:
Product:UIKit Swift Product Version:
Classification: Reproducible:Always
 
Summary:
The method UIStackView.insertArrangedSubview(_:at:) is uncallable with a variable argument for index. It seems to have an inconsistent parameter type annotation for the index parameter. If Int is used, the expected argument type is UInt. If UInt is used, the expected argument type is Int.

Steps to Reproduce:
Create a playground like the following:

import UIKit

let sv = UIStackView()
let v = UIView()
let index: Int = 0
sv.insertArrangedSubview(v, at: index)

Expected Results:
The playground runs successfully

Actual Results:
The following error is printed in the playground console:

Playground execution failed: error: scratch.playground:1:33: error: cannot convert value of type 'Int' to expected argument type 'UInt'
sv.insertArrangedSubview(v, at: index)
                                ^~~~~
                                UInt()

If the index parameter is changed to UInt, the same error is returned, but shown as an in-playground line error with fix-it rather than in the console. It looks like the playground gets further in this case and begins executing before the fix-it is shown.

Version:
XCode 8 Beta 6, Xcode 7.3.1 (7D1014)

Notes:
I reproduced this issue in both Xcode 7 in Swift 2.2, and Xcode 8 in Swift 3.0
Using a literal directly does not trigger this issue.

I’ve attached both playgrounds used to test this in Swift 3.0 in Xcode 8 Beta 6.

Configuration:
Xcode Playgrounds, iOS Projects

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!