标签: swift function generics protocols
我有
protocol A { } class M: A { } func foo<T: A>(t: T) { print("\(t)") } let m = M() foo(m)
此代码按预期工作,但是当我尝试将m转换为A
let m = M() as A foo(m)
我收到了错误error: cannot invoke 'foo' with an argument list of type '(A)' foo(m)
error: cannot invoke 'foo' with an argument list of type '(A)' foo(m)
我在这里做错了什么?