@@ -8193,31 +8193,44 @@ bool UnableToInferGenericPackElementType::diagnoseAsError() {
81938193 auto path = locator->getPath ();
81948194
81958195 if (path.size () > 1 ) {
8196+
81968197 const auto applyArgToParamElt = (path.end () - 2 )->getAs <LocatorPathElt::ApplyArgToParam>();
8198+ const auto packElementElt = (path.end () - 1 )->getAs <LocatorPathElt::PackElement>();
81978199
81988200 if (!applyArgToParamElt)
81998201 return false ;
82008202
8201- unsigned eltIdx = applyArgToParamElt->getArgIdx ();
82028203 auto anchor = getAnchor ();
82038204
8204-
82058205 // `nil` appears as an element of generic pack params, let's record a
82068206 // specify contextual type for nil fix.
82078207 if (isExpr<NilLiteralExpr>(anchor)) {
82088208 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+ }
82108224 }
82118225
8212- // unable to infer the type of an element of generic pack params
8213- emitDiagnostic (diag::could_not_infer_pack_element, eltIdx);
82148226 return true ;
82158227 }
82168228
82178229 return false ;
82188230}
82198231
82208232
8233+
82218234static std::pair<StringRef, StringRef>
82228235getImportModuleAndDefaultType (const ASTContext &ctx,
82238236 const ObjectLiteralExpr *expr) {
0 commit comments