Skip to content

Commit c2831cd

Browse files
committed
[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.
1 parent a6e84b3 commit c2831cd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ ValueDecl *RequirementFailure::getDeclRef() const {
257257
return cast<ValueDecl>(getDC()->getAsDecl());
258258
}
259259

260+
if (contextualPurpose == CTP_DefaultParameter ||
261+
contextualPurpose == CTP_AutoclosureDefaultParameter) {
262+
return cast<ValueDecl>(getDC()->getParent()->getAsDecl());
263+
}
264+
260265
return getAffectedDeclFromType(contextualTy);
261266
}
262267

0 commit comments

Comments
 (0)