Skip to content

Commit 430aa8d

Browse files
committed
[CSDiagnostics] Check applyArgToParamElt for presence
1 parent 1fa5ac4 commit 430aa8d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8221,13 +8221,14 @@ bool UnableToInferGenericPackElementType::diagnoseAsError() {
82218221
if (auto *calleeLocator = getSolution().getCalleeLocator(locator)) {
82228222
if (const auto choice = getOverloadChoiceIfAvailable(calleeLocator)) {
82238223
if (auto *decl = choice->choice.getDeclOrNull()) {
8224-
const auto applyArgToParamElt =
8225-
(path.end() - 2)->getAs<LocatorPathElt::ApplyArgToParam>();
8226-
if (auto paramDecl =
8227-
getParameterAt(decl, applyArgToParamElt->getParamIdx())) {
8228-
emitDiagnosticAt(
8229-
paramDecl->getLoc(), diag::note_in_opening_pack_element,
8230-
packElementElt->getIndex(), paramDecl->getNameStr());
8224+
if (auto applyArgToParamElt =
8225+
locator->findFirst<LocatorPathElt::ApplyArgToParam>()) {
8226+
if (auto paramDecl =
8227+
getParameterAt(decl, applyArgToParamElt->getParamIdx())) {
8228+
emitDiagnosticAt(
8229+
paramDecl->getLoc(), diag::note_in_opening_pack_element,
8230+
packElementElt->getIndex(), paramDecl->getNameStr());
8231+
}
82318232
}
82328233
}
82338234
}

0 commit comments

Comments
 (0)