<div dir="ltr">Hello,<div><br></div><div>First, some background. I&#39;m currently working on refactoring the way mirrors are handled within the Swift standard library (conversion from use of _Reflectable and _MirrorType to CustomReflectable).</div><div><br></div><div>Note that the _MirrorType protocol exposes an &#39;objectIdentifier&#39; property which is only relevant for class instances. Each type&#39;s mirror would have to manually implement this property, with mirrors for non-class types expected to return nil.</div><div><br></div><div>CustomReflectable moves away from each type having a custom _MirrorType-conforming mirror type in favor of using Mirror for everything, which means that certain manually specified properties such as &#39;objectIdentifier&#39; and &#39;summary&#39; disappear, and must be replaced by other language features.</div><div><br></div><div>Now, the current way I distinguish between classes and non-class types (for the dump() function) is through the following code (variable names are made up):</div><div><br></div><div>if let thisClassThing = thisThing as? AnyObject {</div><div>  let theIdentifier = ObjectIdentifier(thisClassThing)</div><div>  // do other stuff...</div><div>}</div><div><br></div><div>(In the context of dump(), this is necessary to ensure that dumping an object with a cycle of references doesn&#39;t result in infinite recursion.)</div><div><br></div><div>However, where this breaks down is when Foundation is imported. In this case, performing as? or is casts/checks on a bridged Swift type such as String or Array&lt;T&gt; results in the test returning true or the type being bridged to an NS* object type.</div><div><br></div><div>My question is whether or not there exist tools in the stdlib to determine whether an instance is an instance of a class or not, while also being able to distinguish between native Swift bridgeable structs and their NS* equivalents. I have a few ideas I&#39;m exploring but I wanted to run this question by the community first to see if there&#39;s anything I&#39;m missing, or if anyone has any good ideas.</div><div><br></div><div>Thanks for your time, and if you have any questions I&#39;d be happy to clarify.</div><div><br></div><div>Best regards,</div><div>Austin</div></div>