1
protocol A { }
class B: A { }
func f(x: Any) {
print(x is A)
}
let x: B? = B()
f(x: x) // false
私はこれが代わりにtrue
であると思います。 Swiftのバグですか?例次のSwift任意のメソッド引数プロトコル準拠失われた
正常に動作してtrue
を返す:
// 1
func f(x: Any) {
print(x is A)
}
let x: B = B() // not optional
f(x: x) // true
// 2
func f(x: Any) {
print(x is B) // check for B
}
let x: B? = B()
f(x: x) // true
[これはバグです](https://bugs.swift.org/browse/SR-6279)。 – Hamish