@@ -1172,13 +1172,10 @@ void ConstraintSystem::openGenericRequirements(
1172
1172
for (unsigned pos = 0 , n = requirements.size (); pos != n; ++pos) {
1173
1173
const auto &req = requirements[pos];
1174
1174
1175
- auto firstType = substFn (req.getFirstType ());
1175
+ Optional<Requirement> openedReq;
1176
+ auto openedFirst = substFn (req.getFirstType ());
1176
1177
1177
1178
auto kind = req.getKind ();
1178
- auto requirementLoc =
1179
- locator.withPathElement (ConstraintLocator::OpenedGeneric)
1180
- .withPathElement (LocatorPathElt::getTypeRequirementComponent (pos));
1181
-
1182
1179
switch (kind) {
1183
1180
case RequirementKind::Conformance: {
1184
1181
auto proto = req.getSecondType ()->castTo <ProtocolType>();
@@ -1188,19 +1185,22 @@ void ConstraintSystem::openGenericRequirements(
1188
1185
if (skipProtocolSelfConstraint && protoDecl == outerDC &&
1189
1186
protoDecl->getSelfInterfaceType ()->isEqual (req.getFirstType ()))
1190
1187
continue ;
1191
- addConstraint ( Requirement (kind, firstType , proto), requirementLoc );
1188
+ openedReq = Requirement (kind, openedFirst , proto);
1192
1189
break ;
1193
1190
}
1194
1191
case RequirementKind::Superclass:
1195
1192
case RequirementKind::SameType:
1196
- addConstraint (Requirement (kind, firstType, substFn (req.getSecondType ())),
1197
- requirementLoc);
1193
+ openedReq = Requirement (kind, openedFirst, substFn (req.getSecondType ()));
1198
1194
break ;
1199
1195
case RequirementKind::Layout:
1200
- addConstraint (Requirement (kind, firstType, req.getLayoutConstraint ()),
1201
- requirementLoc);
1196
+ openedReq = Requirement (kind, openedFirst, req.getLayoutConstraint ());
1202
1197
break ;
1203
1198
}
1199
+
1200
+ addConstraint (
1201
+ *openedReq,
1202
+ locator.withPathElement (ConstraintLocator::OpenedGeneric)
1203
+ .withPathElement (LocatorPathElt::getTypeRequirementComponent (pos)));
1204
1204
}
1205
1205
}
1206
1206
0 commit comments