Skip to content

Commit 49cc219

Browse files
committed
[CSBindings] Don't infer protocol types from the base of an unresolved member chain
1 parent 7009207 commit 49cc219

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,13 @@ PotentialBindings::inferFromRelational(Constraint *constraint) {
10001000
if (!BGT || !isKnownKeyPathDecl(CS.getASTContext(), BGT->getDecl()))
10011001
return None;
10021002
}
1003+
1004+
// Don't allow a protocol type to get propagated from the base to the result
1005+
// type of a chain, Result should always be a concrete type which conforms
1006+
// to the protocol inferred for the base.
1007+
if (locator->isLastElement<LocatorPathElt::UnresolvedMemberChainResult>() &&
1008+
kind == AllowedBindingKind::Supertypes && type->is<ProtocolType>())
1009+
return None;
10031010
}
10041011

10051012
// If the source of the binding is 'OptionalObject' constraint

0 commit comments

Comments
 (0)