I know it is possible to pass class type to a function in swift:
func setGeneric(type: T.Type){ } setGeneric(Int.self)
But how we can
You can force the downcast (as!) as below
func getGeneric() -> T.Type { return Int.self as! T.Type }
But out of the function scope, you need to indicate the returned type:
var t:Int.Type = getGeneric()