Skip to content

Commit 99d3bd8

Browse files
committed
AST: Don't produce 'any Copyable & Escapable' from TypeJoin::visitProtocolType()
1 parent 34def0e commit 99d3bd8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/AST/TypeJoinMeet.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,18 @@ CanType TypeJoin::visitProtocolType(CanType second) {
460460
auto *secondDecl =
461461
cast<ProtocolDecl>(second->getNominalOrBoundGenericNominal());
462462

463-
if (firstDecl->getInheritedProtocols().empty() &&
464-
secondDecl->getInheritedProtocols().empty())
463+
SmallVector<Type, 4> firstMembers;
464+
for (auto *decl : firstDecl->getInheritedProtocols())
465+
if (!decl->getInvertibleProtocolKind())
466+
firstMembers.push_back(decl->getDeclaredInterfaceType());
467+
468+
SmallVector<Type, 4> secondMembers;
469+
for (auto *decl : secondDecl->getInheritedProtocols())
470+
if (!decl->getInvertibleProtocolKind())
471+
secondMembers.push_back(decl->getDeclaredInterfaceType());
472+
473+
if (firstMembers.empty() &&
474+
secondMembers.empty())
465475
return TheAnyType;
466476

467477
if (firstDecl->inheritsFrom(secondDecl))
@@ -473,14 +483,6 @@ CanType TypeJoin::visitProtocolType(CanType second) {
473483
// One isn't the supertype of the other, so instead, treat each as
474484
// if it's a protocol composition of its inherited members, and join
475485
// those.
476-
SmallVector<Type, 4> firstMembers;
477-
for (auto *decl : firstDecl->getInheritedProtocols())
478-
firstMembers.push_back(decl->getDeclaredInterfaceType());
479-
480-
SmallVector<Type, 4> secondMembers;
481-
for (auto *decl : secondDecl->getInheritedProtocols())
482-
secondMembers.push_back(decl->getDeclaredInterfaceType());
483-
484486
return computeProtocolCompositionJoin(firstMembers, secondMembers);
485487
}
486488

0 commit comments

Comments
 (0)