The type casting operator only accepts types and can't process expressions on its right side

Originator:oscar
Number:rdar://23622714 Date Originated:19-Nov-2015
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.1.1
Classification: Reproducible:Always
 
Summary:
It would be nice if the type casting operator accepted expressions on its right side.

Steps to Reproduce:
The type casting operator only accepts types and can't process expressions on its right side.

Having a class A, and a subclass of A, B:

class A {}
class B: A {}

And a function that returns the passed type:

func type<T: A>(t: T.Type) -> T.Type {
    return t
}

The following scenario works:

let b = B()
let a = (b as A)

However the following scenario doesn't:

let b = B()
let a = (b as type(A))

Expected Results:
-

Actual Results:
-

Version:
Xcode 7.1.1 & Swift 2.1

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!