CastOptimizer: Fix for opaque archetypes

The fallthrough path of this function assumes failure :(.

rdar://50544445
This commit is contained in:
Arnold Schwaighofer
2019-05-07 11:01:26 -07:00
parent 3658b6c786
commit dce6ca766b
2 changed files with 23 additions and 0 deletions

View File

@@ -307,6 +307,10 @@ swift::classifyDynamicCast(ModuleDecl *M,
bool isWholeModuleOpts) {
if (source == target) return DynamicCastFeasibility::WillSucceed;
// Return a conservative answer for opaque archetypes for now.
if (source->hasOpaqueArchetype() || target->hasOpaqueArchetype())
return DynamicCastFeasibility::MaySucceed;
auto sourceObject = source.getOptionalObjectType();
auto targetObject = target.getOptionalObjectType();