- The following code gives different results depending on whether optimization is turned on:
With an unoptimized build, it prints:
However, in an optimized build (release configuration in Xcode), it prints:
The optimization discrepancy is definitely a bug. I think the unoptimized output is the correct one — type(of:) should always return a concrete type, never a protocol … right?
(Apologies if this is a duplicate. I found it a difficult one to search for.)