Skip to content

Commit 3a145f5

Browse files
committed
[CSSimplify] Change equality semantics between base and result of unresolved member ref
Since it's now possible to infer base type of an unresolved member reference to be a protocol type we need to adjust `matchTypes` to check conformance instead of type equality between base (represented by a protocol) and chain's concrete result type.
1 parent ee8b87e commit 3a145f5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5507,6 +5507,19 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
55075507
}
55085508
}
55095509
}
5510+
5511+
if (elt->is<LocatorPathElt::UnresolvedMemberChainResult>()) {
5512+
if (type1->is<ProtocolType>() && !type2->isTypeVariableOrMember()) {
5513+
auto result = simplifyConformsToConstraint(
5514+
type2, type1, ConstraintKind::ConformsTo,
5515+
locator.withPathElement(LocatorPathElt::TypeParameterRequirement(
5516+
0, RequirementKind::Conformance)),
5517+
subflags);
5518+
5519+
return result == SolutionKind::Error ? getTypeMatchFailure(locator)
5520+
: getTypeMatchSuccess();
5521+
}
5522+
}
55105523
}
55115524

55125525
if (kind == ConstraintKind::BindParam) {

0 commit comments

Comments
 (0)