SIL: Workaround for GenericSignatureBuilder bug

The GSB will drop same-type requirements sometimes, when the
right hand side is smaller than the left. Change the order
when adding these requirements, which seems to work well
enough for my reduced testcase.

Also, ensure that everything works correctly with the
RequirementMachine, which doesn't have the same underlying
problems with same-type requirement handling.

Fixes rdar://86431977.
This commit is contained in:
Slava Pestov
2021-12-15 23:14:41 -05:00
parent 47037aef65
commit 20a913d208
3 changed files with 46 additions and 2 deletions

View File

@@ -1649,8 +1649,8 @@ public:
newGPMapping.insert({gp, newParamTy});
auto substGPTy = Type(gp).subst(substGPMap)->castTo<GenericTypeParamType>();
substRequirements.push_back(Requirement(RequirementKind::SameType,
substGPTy,
newParamTy));
newParamTy,
substGPTy));
assert(!substReplacementTypes[substGPTy->getIndex()]);
substReplacementTypes[substGPTy->getIndex()] = substParamTy;
}