在Xcode8 beta6中,以下代码将引发警告:'is'test始终为true。但它不会打印通过。
struct TestStruct {
}
//warning: 'is' test is always true
if TestStruct() is AnyObject {
print("pass")
}
以下代码将引发警告:从'T'到'AnyObject'的条件转换始终成功
public static func register<T>(_ protocolType: T.Type, observer: T) {
//Warning: Conditional cast from 'T' to 'AnyObject' always succeeds
guard let object = observer as? AnyObject else {
fatalError("expecting reference type but found value type: \(observer)")
}
//...
}
汪汪一只猫
慕娘9325324