[ConstraintSystem] Adjust locator for implicit conversions between tuple elements

Drop `TupleType` element which is only used for diagnostics and
cannot be re-created by `ExprRewriter` during solution application.

Resolves: rdar://97389698
This commit is contained in:
Pavel Yaskevich
2022-07-21 12:05:02 -07:00
parent 2f78f5a7b3
commit d0289dc736
2 changed files with 17 additions and 0 deletions

View File

@@ -452,6 +452,18 @@ ConstraintLocator *ConstraintSystem::getImplicitValueConversionLocator(
anchor = ASTNode();
path.clear();
}
// If conversion is for a tuple element, let's drop `TupleType`
// components from the path since they carry information for
// diagnostics that `ExprRewriter` won't be able to re-construct
// during solution application.
if (!path.empty() && path.back().is<LocatorPathElt::TupleElement>()) {
path.erase(llvm::remove_if(path,
[](const LocatorPathElt &elt) {
return elt.is<LocatorPathElt::TupleType>();
}),
path.end());
}
}
return getConstraintLocator(/*base=*/getConstraintLocator(anchor, path),