swift
52eb3b56 - [cast-optimizer] Fix incorrect handling of returned pointers.

Commit
4 years ago
[cast-optimizer] Fix incorrect handling of returned pointers. Put simply, the method Type::getAnyNominal() returns either a nominal type or a nullptr. We are then casting it using dyn_cast to a ProtocolDecl. dyn_cast is not allowed to handle nullptrs... hence the crash. The fix is to use the API dyn_cast_or_null, the specific cast meant for this case! In terms of how this effects the flow of the code in such a case, we will just bail early if we have a non-nominal type today (which to me means at least metatypes, which is this case). I included a test case that we crash on without my change today and just do not optimize. rdar://87989767
Author
Committer
Parents
Loading