You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
protocolProtocol{}enumEnum:Protocol{case `case` }structStruct:Protocol{}classClass:Protocol{}letenumInstance:Any=Enum.case
letstructInstance:Any=Struct()letclassInstance:Any=Class()print(enumInstance is Protocol)// true, as expectedprint(structInstance is Protocol)// true, as expectedprint(classInstance is Protocol)// true, as expectedfunc instanceCheck<TheType>(_ instance:Any, _:TheType.Type)->Bool{return instance is TheType}print(instanceCheck(enumInstance,Protocol.self))// true, as expectedprint(instanceCheck(structInstance,Protocol.self))// true, as expectedprint(instanceCheck(classInstance,Protocol.self))// true, as expectedletenumType:Any.Type=Enum.self
letstructType:Any.Type=Struct.self
letclassType:Any.Type=Class.self
print(enumType is Protocol.Type)// true, as expectedprint(structType is Protocol.Type)// true, as expectedprint(classType is Protocol.Type)// true, as expectedfunc typeCheck<TheType>(_ type:Any.Type, _:TheType.Type)->Bool{return type is TheType.Type}print(typeCheck(enumType,Protocol.self))// false, surprisinglyprint(typeCheck(structType,Protocol.self))// false, surprisinglyprint(typeCheck(classType,Protocol.self))// false, surprisingly
Attachment: Download
Environment
Xcode Version 12.0 (12A7209) build in toolchain
Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
Target: x86_64-apple-darwin19.5.0
Additional Detail from JIRA
md5: 16f605757d589eb4f960b3df34c9414a
Issue Description:
There is an inconsistent behavior of the type checking primitives with generic metatypes.
When I use xcode 11.7 I don't have this problem, instead I have this problem with xcode 12
The code is available in the MyPlayground.playground.zip
Some discusstion on forums
The text was updated successfully, but these errors were encountered: