Hello everyone. This is my first contribution to Swift Evolution. In summary: 
It would be nice if the type casting operator accepted expressions on its right 
side.


So, basically, 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))




Having the “as” accept expressions on its right side would be really useful and 
could enable some truly great generic algorithm implementations.




Looking forward to what you guys think about this.

— Oscar Swanros | @swanros

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to