From 4ffffb110a24e69f1323c6e02e0c220e77f646ac Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Sat, 28 Jul 2018 19:12:22 -0700 Subject: [PATCH] [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. --- lib/SIL/DynamicCasts.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/SIL/DynamicCasts.cpp b/lib/SIL/DynamicCasts.cpp index 8bbb6c03148..0b82ea3238a 100644 --- a/lib/SIL/DynamicCasts.cpp +++ b/lib/SIL/DynamicCasts.cpp @@ -490,17 +490,6 @@ swift::classifyDynamicCast(ModuleDecl *M, && sourceFunction.getResult() == targetFunction.getResult()) return DynamicCastFeasibility::WillSucceed; - auto isSubstitutable = [](CanType a, CanType b) -> bool { - // FIXME: Unnecessarily conservative; should structurally check for - // substitutability. - return a == b || a->hasArchetype() || b->hasArchetype(); - }; - - if (isSubstitutable(sourceFunction.getInput(), targetFunction.getInput()) - && isSubstitutable(targetFunction.getInput(), - targetFunction.getResult())) - return DynamicCastFeasibility::MaySucceed; - return DynamicCastFeasibility::WillFail; } }