Skip to content

Commit 8f2aadd

Browse files
committed
[CSRanking] Amend concrete-over-protocol logic to only do an is-a check
As discussed in swiftlang#18951, we don't want to be comparing two different protocol decls here, as that could lead to spurious 'is more specialized' results. I'm not aware of any case that currently trips this logic up though, so no tests to accompany.
1 parent 698dd39 commit 8f2aadd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Sema/CSRanking.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,10 @@ static bool isDeclAsSpecializedAs(TypeChecker &tc, DeclContext *dc,
471471
// }
472472
//
473473
if (tc.Context.isSwiftVersionAtLeast(5) && !isDynamicOverloadComparison) {
474-
auto *proto1 = dyn_cast<ProtocolDecl>(outerDC1);
475-
auto *proto2 = dyn_cast<ProtocolDecl>(outerDC2);
476-
if (proto1 != proto2)
477-
return proto2;
474+
auto inProto1 = isa<ProtocolDecl>(outerDC1);
475+
auto inProto2 = isa<ProtocolDecl>(outerDC2);
476+
if (inProto1 != inProto2)
477+
return inProto2;
478478
}
479479

480480
Type type1 = decl1->getInterfaceType();

0 commit comments

Comments
 (0)