@@ -3991,6 +3991,8 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
3991
3991
auto protocolSubMap = SubstitutionMap::getProtocolSubstitutions (
3992
3992
proto, selfType.getDependentType (*this ), ProtocolConformanceRef (proto));
3993
3993
3994
+ auto result = ConstraintResult::Resolved;
3995
+
3994
3996
// Use the requirement signature to avoid rewalking the entire protocol. This
3995
3997
// cannot compute the requirement signature directly, because that may be
3996
3998
// infinitely recursive: this code is also used to construct it.
@@ -4007,19 +4009,20 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4007
4009
auto reqResult = substReq
4008
4010
? addRequirement (*substReq, innerSource, nullptr )
4009
4011
: ConstraintResult::Conflicting;
4010
- if (isErrorResult (reqResult)) return reqResult;
4012
+ if (isErrorResult (reqResult) && !isErrorResult (result))
4013
+ result = reqResult;
4011
4014
}
4012
4015
4013
- return ConstraintResult::Resolved ;
4016
+ return result ;
4014
4017
}
4015
4018
4016
4019
if (!onlySameTypeConstraints) {
4017
4020
// Add all of the inherited protocol requirements, recursively.
4018
4021
auto inheritedReqResult =
4019
4022
addInheritedRequirements (proto, selfType.getUnresolvedType (), source,
4020
4023
nullptr );
4021
- if (isErrorResult (inheritedReqResult))
4022
- return inheritedReqResult;
4024
+ if (isErrorResult (inheritedReqResult) && ! isErrorResult (inheritedReqResult) )
4025
+ result = inheritedReqResult;
4023
4026
}
4024
4027
4025
4028
// Add any requirements in the where clause on the protocol.
@@ -4048,7 +4051,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4048
4051
getASTContext ()),
4049
4052
innerSource);
4050
4053
4051
- return ConstraintResult::Resolved ;
4054
+ return result ;
4052
4055
}
4053
4056
4054
4057
// Remaining logic is not relevant in ObjC protocol cases.
@@ -4156,11 +4159,13 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4156
4159
Type assocType =
4157
4160
DependentMemberType::get (selfType.getDependentType (*this ), assocTypeDecl);
4158
4161
if (!onlySameTypeConstraints) {
4162
+ (void ) resolve (assocType, source);
4163
+
4159
4164
auto assocResult =
4160
4165
addInheritedRequirements (assocTypeDecl, assocType, source,
4161
4166
/* inferForModule=*/ nullptr );
4162
- if (isErrorResult (assocResult))
4163
- return assocResult;
4167
+ if (isErrorResult (assocResult) && ! isErrorResult (result) )
4168
+ result = assocResult;
4164
4169
}
4165
4170
4166
4171
// Add requirements from this associated type's where clause.
@@ -4314,7 +4319,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
4314
4319
}
4315
4320
}
4316
4321
4317
- return ConstraintResult::Resolved ;
4322
+ return result ;
4318
4323
}
4319
4324
4320
4325
ConstraintResult GenericSignatureBuilder::addConformanceRequirement (
@@ -8873,9 +8878,23 @@ RequirementSignatureRequest::evaluate(Evaluator &evaluator,
8873
8878
auto rqmResult = buildViaRQM ();
8874
8879
auto gsbResult = buildViaGSB ();
8875
8880
8876
- if (rqmResult.size () != gsbResult.size () ||
8877
- !std::equal (rqmResult.begin (), rqmResult.end (),
8878
- gsbResult.begin ())) {
8881
+ // For now, only compare conformance requirements, since those are the
8882
+ // important ones from the ABI perspective.
8883
+ SmallVector<Requirement, 2 > rqmConformances;
8884
+ for (auto req : rqmResult) {
8885
+ if (req.getKind () == RequirementKind::Conformance)
8886
+ rqmConformances.push_back (req);
8887
+ }
8888
+ SmallVector<Requirement, 2 > gsbConformances;
8889
+ for (auto req : gsbResult) {
8890
+ if (req.getKind () == RequirementKind::Conformance)
8891
+ gsbConformances.push_back (req);
8892
+ }
8893
+
8894
+ if (rqmConformances.size () != gsbConformances.size () ||
8895
+ !std::equal (rqmConformances.begin (),
8896
+ rqmConformances.end (),
8897
+ gsbConformances.begin ())) {
8879
8898
llvm::errs () << " RequirementMachine protocol signature minimization is broken:\n " ;
8880
8899
llvm::errs () << " Protocol: " << proto->getName () << " \n " ;
8881
8900
0 commit comments