@@ -8193,31 +8193,44 @@ bool UnableToInferGenericPackElementType::diagnoseAsError() {
8193
8193
auto path = locator->getPath ();
8194
8194
8195
8195
if (path.size () > 1 ) {
8196
+
8196
8197
const auto applyArgToParamElt = (path.end () - 2 )->getAs <LocatorPathElt::ApplyArgToParam>();
8198
+ const auto packElementElt = (path.end () - 1 )->getAs <LocatorPathElt::PackElement>();
8197
8199
8198
8200
if (!applyArgToParamElt)
8199
8201
return false ;
8200
8202
8201
- unsigned eltIdx = applyArgToParamElt->getArgIdx ();
8202
8203
auto anchor = getAnchor ();
8203
8204
8204
-
8205
8205
// `nil` appears as an element of generic pack params, let's record a
8206
8206
// specify contextual type for nil fix.
8207
8207
if (isExpr<NilLiteralExpr>(anchor)) {
8208
8208
emitDiagnostic (diag::unresolved_nil_literal);
8209
- return true ;
8209
+ }
8210
+ else {
8211
+ // unable to infer the type of an element of generic pack params
8212
+ emitDiagnostic (diag::could_not_infer_pack_element, packElementElt->getIndex ());
8213
+ }
8214
+
8215
+ // emit callee side diagnostics
8216
+ auto applyExpr = castToExpr<ApplyExpr>(locator->getAnchor ());
8217
+ if (auto * Fn = applyExpr->getFn ()) {
8218
+ if (const auto DeclRef = Fn->getReferencedDecl ()) {
8219
+ auto paramDecl = getParameterAt (DeclRef, applyArgToParamElt->getParamIdx ());
8220
+ emitDiagnosticAt (
8221
+ paramDecl->getLoc (), diag::note_in_opening_pack_element,
8222
+ packElementElt->getIndex () + 1 , paramDecl->getNameStr ());
8223
+ }
8210
8224
}
8211
8225
8212
- // unable to infer the type of an element of generic pack params
8213
- emitDiagnostic (diag::could_not_infer_pack_element, eltIdx);
8214
8226
return true ;
8215
8227
}
8216
8228
8217
8229
return false ;
8218
8230
}
8219
8231
8220
8232
8233
+
8221
8234
static std::pair<StringRef, StringRef>
8222
8235
getImportModuleAndDefaultType (const ASTContext &ctx,
8223
8236
const ObjectLiteralExpr *expr) {
0 commit comments