what check on variable type would be equivalent to val is T
?
protocol P {}
struct S: P {}
func foo<T, R>(_ val: T, _ type: R.Type) {
let a = val is R
let b = T.self == type // FIXME. smth like <= ?
assert(a == b)
}
foo(0, Int.self) // ok
foo([0], [Int].self) // ok
foo(0, Any.self) // assert fails
foo([0], [Any].self) // assert fails
foo(S(), P.self) // assert fails
foo([S()], [P].self) // assert fails
print("done")