@@ -8202,20 +8202,17 @@ bool UnableToInferClosureReturnType::diagnoseAsError() {
8202
8202
bool UnableToInferGenericPackElementType::diagnoseAsError () {
8203
8203
auto *locator = getLocator ();
8204
8204
auto path = locator->getPath ();
8205
-
8206
- const auto applyArgToParamElt =
8207
- (path.end () - 2 )->getAs <LocatorPathElt::ApplyArgToParam>();
8208
- const auto packElementElt =
8209
- (path.end () - 1 )->getAs <LocatorPathElt::PackElement>();
8210
- if (!applyArgToParamElt || !packElementElt) {
8211
- return false ;
8212
- }
8205
+ const auto packElementElt = (path.end () - 1 )->getAs <LocatorPathElt::PackElement>();
8213
8206
8214
8207
if (isExpr<NilLiteralExpr>(getAnchor ())) {
8215
8208
// `nil` appears as an element of generic pack params, let's record a
8216
8209
// specify contextual type for nil fix.
8217
8210
emitDiagnostic (diag::unresolved_nil_literal);
8218
8211
} else {
8212
+ if (llvm::any_of (getSolution ().Fixes , [&locator](const ConstraintFix *fix) {
8213
+ return fix->getLocator () == locator;
8214
+ }))
8215
+ return false ;
8219
8216
// unable to infer the type of an element of generic pack params
8220
8217
emitDiagnostic (diag::could_not_infer_pack_element,
8221
8218
packElementElt->getIndex ());
@@ -8226,6 +8223,8 @@ bool UnableToInferGenericPackElementType::diagnoseAsError() {
8226
8223
if (auto *calleeLocator = getSolution ().getCalleeLocator (locator)) {
8227
8224
if (const auto choice = getOverloadChoiceIfAvailable (calleeLocator)) {
8228
8225
if (auto *decl = choice->choice .getDeclOrNull ()) {
8226
+ const auto applyArgToParamElt =
8227
+ (path.end () - 2 )->getAs <LocatorPathElt::ApplyArgToParam>();
8229
8228
if (auto paramDecl =
8230
8229
getParameterAt (decl, applyArgToParamElt->getParamIdx ())) {
8231
8230
emitDiagnosticAt (
0 commit comments