Skip to content

Commit 4ffffb1

Browse files
committed
[SIL] Remove what amounts to dead code from classifyDynamicCast().
The archetype tests in the code being removed will never succeed because there is code earlier in the function testing for any archetypes in either type, and that path always returns. The remaining test is broken (it's comparing source input and target input and then target input to target result rather than comparing the source input and target input and then source result and target result), and is just duplicating the test that happens above. If we really want to do a better test for substitutability we can do so at a later time. In the meantime, I don't think it makes sense to leave redundant comparisons and an unreachable return in place.
1 parent 834ad9e commit 4ffffb1

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

lib/SIL/DynamicCasts.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,17 +490,6 @@ swift::classifyDynamicCast(ModuleDecl *M,
490490
&& sourceFunction.getResult() == targetFunction.getResult())
491491
return DynamicCastFeasibility::WillSucceed;
492492

493-
auto isSubstitutable = [](CanType a, CanType b) -> bool {
494-
// FIXME: Unnecessarily conservative; should structurally check for
495-
// substitutability.
496-
return a == b || a->hasArchetype() || b->hasArchetype();
497-
};
498-
499-
if (isSubstitutable(sourceFunction.getInput(), targetFunction.getInput())
500-
&& isSubstitutable(targetFunction.getInput(),
501-
targetFunction.getResult()))
502-
return DynamicCastFeasibility::MaySucceed;
503-
504493
return DynamicCastFeasibility::WillFail;
505494
}
506495
}

0 commit comments

Comments
 (0)