func giveMeZero<T>() -> T? {
print(T.self)
return 0 as? T
}
When the above function is called without sufficient type context, Swift infers the return type as the metatype 'Any.Type', where I'd expect it to infer 'Any' or maybe offer the ambiguity error.
// Calling code without type context, which exhibits the said behaviour
// prints 'no', since it's trying to cast 0 to Any.Type
if giveMeZero() != nil {
print("yes")
} else {
print("no")
}
Output:
"Any.Type\n"
"no\n"