Diagnostics: invertibles and conformsTo

This commit is contained in:
Kavon Farvardin
2024-02-13 15:14:39 -08:00
parent bab9627c5f
commit 88e4ece3ca

View File

@@ -4575,7 +4575,17 @@ bool UnintendedExtraGenericParamMemberFailure::diagnoseAsError() {
SourceLoc loc = genericTy->getDecl()->getSourceRange().End;
StringRef replacement;
if (archetype->getConformsTo().size()) {
// FIXME: this won't handle an explicit Copyable written in source, but it's
// close enough.
bool conformsToAnExplicitRequirement = false;
for (auto proto : archetype->getConformsTo()) {
if (proto->getInvertibleProtocolKind())
continue;
conformsToAnExplicitRequirement = true;
break;
}
if (conformsToAnExplicitRequirement) {
loc = loc.getAdvancedLoc(
archetype->getConformsTo().back()->getName().getLength());
replacement = " &";