[CSDiagnostics] Adjust generic requirement diagnostics for inference from defaults

Contextual type could be a type variable or a type with type variables
that have a set of generic requirements, so affected declaration is
the owner of the generic parameter.
This commit is contained in:
Pavel Yaskevich
2022-02-17 09:40:34 -08:00
parent a6e84b3d05
commit c2831cd2a9

View File

@@ -257,6 +257,11 @@ ValueDecl *RequirementFailure::getDeclRef() const {
return cast<ValueDecl>(getDC()->getAsDecl());
}
if (contextualPurpose == CTP_DefaultParameter ||
contextualPurpose == CTP_AutoclosureDefaultParameter) {
return cast<ValueDecl>(getDC()->getParent()->getAsDecl());
}
return getAffectedDeclFromType(contextualTy);
}