Is that what you guys wanted to achieve?
@inline(never)
func opaqueCast<T,U>(_ x: T, _: U.Type) -> Bool {
return x is U
}
let foo: Any = "Foo"
let bar: Any = NSString(string: "Bar")
let fooIsString = foo is String // true
opaqueCast(type(of: foo), String.Type.self) // true
let fooIsNSString = foo is NSString // true
opaqueCast(type(of: foo), NSString.Type.self) // false
let barIsString = bar is String // true
opaqueCast(type(of: bar), String.Type.self) // false
let barIsNSString = bar is NSString // true
opaqueCast(type(of: bar), NSString.Type.self) // true
Joe Groff showed me this little trick when is cast was bugged in some Xcode
beta for Swift 1.2.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution