File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -3435,7 +3435,8 @@ bool MissingMemberFailure::diagnoseForSubscriptMemberWithTupleBase() const {
34353435 auto locator = getLocator ();
34363436 auto baseType = resolveType (getBaseType ())->getWithoutSpecifierType ();
34373437
3438- if (!locator->isLastElement <LocatorPathElt::SubscriptMember>())
3438+ auto *SE = getAsExpr<SubscriptExpr>(locator->getAnchor ());
3439+ if (!SE)
34393440 return false ;
34403441
34413442 auto tupleType = baseType->getAs <TupleType>();
@@ -3444,9 +3445,7 @@ bool MissingMemberFailure::diagnoseForSubscriptMemberWithTupleBase() const {
34443445 if (!tupleType || tupleType->getNumElements () == 0 )
34453446 return false ;
34463447
3447- auto *SE = castToExpr<SubscriptExpr>(locator->getAnchor ());
34483448 auto *index = SE->getIndex ();
3449-
34503449 if (SE->getNumArguments () == 1 ) {
34513450 auto *literal =
34523451 dyn_cast<IntegerLiteralExpr>(index->getSemanticsProvidingExpr ());
@@ -3481,8 +3480,7 @@ bool MissingMemberFailure::diagnoseForSubscriptMemberWithTupleBase() const {
34813480 dyn_cast<StringLiteralExpr>(index->getSemanticsProvidingExpr ());
34823481 if (stringLiteral && !stringLiteral->getValue ().empty () &&
34833482 llvm::any_of (tupleType->getElements (), [&](TupleTypeElt element) {
3484- return !element.getName ().empty () &&
3485- element.getName ().str () == stringLiteral->getValue ();
3483+ return element.getName ().is (stringLiteral->getValue ());
34863484 })) {
34873485 llvm::SmallString<16 > dotAccess;
34883486 llvm::raw_svector_ostream OS (dotAccess);
Original file line number Diff line number Diff line change 29692969
29702970 - id : could_not_find_subscript_member_tuple
29712971 msg : >-
2972- cannot access element using subscript for tuple type %0;
2973- use '.' notation instead
2972+ cannot access element using subscript for tuple type %0; use '.' notation instead
29742973
29752974 - id : could_not_find_subscript_member_tuple_did_you_mean_use_dot
29762975 msg : >-
2977- cannot access element using subscript for tuple type %0;
2978- did you mean to use '.%1'?
2976+ cannot access element using subscript for tuple type %0; did you mean to use '.%1'?
29792977
29802978 - id : could_not_find_enum_case
29812979 msg : >-
You can’t perform that action at this time.
0 commit comments