在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)") } //...}
- 3 回答
- 0 关注
- 496 浏览
添加回答
举报
0/150
提交
取消