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 {
3435
3435
auto locator = getLocator ();
3436
3436
auto baseType = resolveType (getBaseType ())->getWithoutSpecifierType ();
3437
3437
3438
- if (!locator->isLastElement <LocatorPathElt::SubscriptMember>())
3438
+ auto *SE = getAsExpr<SubscriptExpr>(locator->getAnchor ());
3439
+ if (!SE)
3439
3440
return false ;
3440
3441
3441
3442
auto tupleType = baseType->getAs <TupleType>();
@@ -3444,9 +3445,7 @@ bool MissingMemberFailure::diagnoseForSubscriptMemberWithTupleBase() const {
3444
3445
if (!tupleType || tupleType->getNumElements () == 0 )
3445
3446
return false ;
3446
3447
3447
- auto *SE = castToExpr<SubscriptExpr>(locator->getAnchor ());
3448
3448
auto *index = SE->getIndex ();
3449
-
3450
3449
if (SE->getNumArguments () == 1 ) {
3451
3450
auto *literal =
3452
3451
dyn_cast<IntegerLiteralExpr>(index->getSemanticsProvidingExpr ());
@@ -3481,8 +3480,7 @@ bool MissingMemberFailure::diagnoseForSubscriptMemberWithTupleBase() const {
3481
3480
dyn_cast<StringLiteralExpr>(index->getSemanticsProvidingExpr ());
3482
3481
if (stringLiteral && !stringLiteral->getValue ().empty () &&
3483
3482
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 ());
3486
3484
})) {
3487
3485
llvm::SmallString<16 > dotAccess;
3488
3486
llvm::raw_svector_ostream OS (dotAccess);
Original file line number Diff line number Diff line change 2969
2969
2970
2970
- id : could_not_find_subscript_member_tuple
2971
2971
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
2974
2973
2975
2974
- id : could_not_find_subscript_member_tuple_did_you_mean_use_dot
2976
2975
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'?
2979
2977
2980
2978
- id : could_not_find_enum_case
2981
2979
msg : >-
You can’t perform that action at this time.
0 commit comments