[CS] Re-order subscript constraint generation

Add the application constraint before the member constraint, which
allows us to get rid of the special-cased delaying logic for dynamic
member subscripts. The diagnostic change here is due to the fact that
we no longer have a simplified type for the result in CSGen, which
would also be the case if we had a disjunction for the member.
This commit is contained in:
Hamish Knight
2025-10-19 13:14:00 +01:00
parent 4403625279
commit f1823786b6
4 changed files with 15 additions and 34 deletions

View File

@@ -11465,22 +11465,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
if (result.actualBaseType)
baseTy = result.actualBaseType;
// If only possible choice to refer to member is via keypath
// dynamic member dispatch, let's delay solving this constraint
// until constraint generation phase is complete, because
// subscript dispatch relies on presence of function application.
if (result.ViableCandidates.size() == 1) {
auto &choice = result.ViableCandidates.front();
if (Phase == ConstraintSystemPhase::ConstraintGeneration &&
choice.isKeyPathDynamicMemberLookup() &&
member.getBaseName().isSubscript()) {
// Let's move this constraint to the active
// list so it could be picked up right after
// constraint generation is done.
return formUnsolved(/*activate=*/true);
}
}
generateOverloadConstraints(
candidates, memberTy, result.ViableCandidates, useDC, locator,
result.getFavoredIndex(), /*requiresFix=*/false,