Skip to content

Commit 5133c97

Browse files
committed
Sema: Clean up leading dot fix logic in simplifyConformsToConstraint()
Tests still pass without this code, including the tests I just added in the previous commit.
1 parent d9e7ddf commit 5133c97

File tree

1 file changed

+4
-44
lines changed

1 file changed

+4
-44
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8859,17 +8859,14 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
88598859
return SolutionKind::Solved;
88608860
}
88618861

8862-
auto formUnsolved = [&](bool activate = false) {
8862+
auto formUnsolved = [&]() {
88638863
// If we're supposed to generate constraints, do so.
88648864
if (flags.contains(TMF_GenerateConstraints)) {
88658865
auto *conformance = Constraint::create(
88668866
*this, kind, type, protocol->getDeclaredInterfaceType(),
88678867
getConstraintLocator(locator));
88688868

88698869
addUnsolvedConstraint(conformance);
8870-
if (activate)
8871-
activateConstraint(conformance);
8872-
88738870
return SolutionKind::Solved;
88748871
}
88758872

@@ -9243,47 +9240,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
92439240

92449241
if (isExpr<UnresolvedMemberExpr>(anchor) &&
92459242
req->is<LocatorPathElt::TypeParameterRequirement>()) {
9246-
auto signature = path[path.size() - 2]
9247-
.castTo<LocatorPathElt::OpenedGeneric>()
9248-
.getSignature();
9249-
auto requirement = signature.getRequirements()[req->getIndex()];
9250-
92519243
auto *memberLoc = getConstraintLocator(anchor, path.front());
9252-
auto overload = findSelectedOverloadFor(memberLoc);
9253-
9254-
// To figure out what is going on here we need to wait until
9255-
// member overload is set in the constraint system.
9256-
if (!overload) {
9257-
// If it's not allowed to generate new constraints
9258-
// there is no way to control re-activation, so this
9259-
// check has to fail.
9260-
if (!flags.contains(TMF_GenerateConstraints))
9261-
return SolutionKind::Error;
9262-
9263-
return formUnsolved(/*activate=*/true);
9264-
}
9265-
9266-
auto *memberRef = overload->choice.getDeclOrNull();
9267-
if (!memberRef)
9268-
return SolutionKind::Error;
9269-
9270-
// If this is a `Self` conformance requirement from a static member
9271-
// reference on a protocol metatype, let's produce a tailored diagnostic.
9272-
if (memberRef->isStatic()) {
9273-
if (hasFixFor(memberLoc,
9274-
FixKind::AllowInvalidStaticMemberRefOnProtocolMetatype))
9275-
return SolutionKind::Solved;
9276-
9277-
if (auto *protocolDecl =
9278-
memberRef->getDeclContext()->getSelfProtocolDecl()) {
9279-
auto selfTy = protocolDecl->getSelfInterfaceType();
9280-
if (selfTy->isEqual(requirement.getFirstType())) {
9281-
auto *fix = AllowInvalidStaticMemberRefOnProtocolMetatype::create(
9282-
*this, memberLoc);
9283-
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
9284-
}
9285-
}
9286-
}
9244+
auto *fix = AllowInvalidStaticMemberRefOnProtocolMetatype::create(
9245+
*this, memberLoc);
9246+
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
92879247
}
92889248

92899249
if (auto *fix =

0 commit comments

Comments
 (0)