Swift 2 converter should remove casts which are no longer necessary

Originator:fluidsonic
Number:rdar://21669510 Date Originated:2015-06-07
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7 Beta 2
Classification:Enhancement Reproducible:Always
 
Summary:
With iOS 9 come generics for Objective-C. These generics make casts like "view.subviews as! [UIView]" unnecessary.

When upgrading a project using "Convert > To Latest Swift Syntax" then the convert replaces for example "view.subviews as! [UIView]" with "view.subviews as [UIView]" which results in an unnecessary cast.
Instead the converter should remove the cast completely as "view.subviews" is already of type [UIView].

Steps to Reproduce:
1. Copy the code from the attached file into a Playground
2. Use "Convert > To Latest Swift Syntax"
3. Notice how there now is an unnecessary cast from [UIView] to [UIView]

Expected Results:
The converter should remove the cast which is now longer necessary.

Actual Results:
There is an unnecessary cast from [UIView] to [UIView]


Attached file:

import UIKit

func test(view: UIView) {
	for _ in view.subviews as! [UIView] {
		// ...
	}
}

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!