@@ -70,8 +70,7 @@ class SemaAnnotator : public ASTWalker {
70
70
bool passReference (ModuleEntity Mod, std::pair<Identifier, SourceLoc> IdLoc);
71
71
72
72
bool passSubscriptReference (ValueDecl *D, SourceLoc Loc,
73
- Optional<AccessKind> AccKind,
74
- bool IsOpenBracket);
73
+ ReferenceMetaData Data, bool IsOpenBracket);
75
74
76
75
bool passCallArgNames (Expr *Fn, TupleExpr *TupleE);
77
76
@@ -265,6 +264,8 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
265
264
!isa<MakeTemporarilyEscapableExpr>(E) &&
266
265
!isa<CollectionUpcastConversionExpr>(E) &&
267
266
!isa<OpaqueValueExpr>(E) &&
267
+ !isa<SubscriptExpr>(E) &&
268
+ !isa<KeyPathExpr>(E) &&
268
269
E->isImplicit ())
269
270
return { true , E };
270
271
@@ -326,16 +327,19 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
326
327
if (SE->hasDecl ())
327
328
SubscrD = SE->getDecl ().getDecl ();
328
329
330
+ ReferenceMetaData data (SemaReferenceKind::SubscriptRef, OpAccess,
331
+ SE->isImplicit ());
332
+
329
333
if (SubscrD) {
330
- if (!passSubscriptReference (SubscrD, E->getLoc (), OpAccess , true ))
334
+ if (!passSubscriptReference (SubscrD, E->getLoc (), data , true ))
331
335
return { false , nullptr };
332
336
}
333
337
334
338
if (!SE->getIndex ()->walk (*this ))
335
339
return { false , nullptr };
336
340
337
341
if (SubscrD) {
338
- if (!passSubscriptReference (SubscrD, E->getEndLoc (), OpAccess , false ))
342
+ if (!passSubscriptReference (SubscrD, E->getEndLoc (), data , false ))
339
343
return { false , nullptr };
340
344
}
341
345
@@ -577,14 +581,14 @@ bool SemaAnnotator::passModulePathElements(
577
581
}
578
582
579
583
bool SemaAnnotator::passSubscriptReference (ValueDecl *D, SourceLoc Loc,
580
- Optional<AccessKind> AccKind ,
584
+ ReferenceMetaData Data ,
581
585
bool IsOpenBracket) {
582
586
CharSourceRange Range = Loc.isValid ()
583
587
? CharSourceRange (Loc, 1 )
584
588
: CharSourceRange ();
585
589
586
- bool Continue = SEWalker. visitSubscriptReference (D, Range, AccKind,
587
- IsOpenBracket);
590
+ bool Continue =
591
+ SEWalker. visitSubscriptReference (D, Range, Data, IsOpenBracket);
588
592
if (!Continue)
589
593
Cancelled = true ;
590
594
return Continue;
@@ -727,13 +731,14 @@ bool SourceEntityWalker::visitDeclReference(ValueDecl *D, CharSourceRange Range,
727
731
728
732
bool SourceEntityWalker::visitSubscriptReference (ValueDecl *D,
729
733
CharSourceRange Range,
730
- Optional<AccessKind> AccKind ,
734
+ ReferenceMetaData Data ,
731
735
bool IsOpenBracket) {
732
736
// Most of the clients treat subscript reference the same way as a
733
737
// regular reference when called on the open bracket and
734
738
// ignore the closing one.
735
- return IsOpenBracket ? visitDeclReference (D, Range, nullptr , nullptr , Type (),
736
- ReferenceMetaData (SemaReferenceKind::SubscriptRef, AccKind)) : true ;
739
+ return IsOpenBracket
740
+ ? visitDeclReference (D, Range, nullptr , nullptr , Type (), Data)
741
+ : true ;
737
742
}
738
743
739
744
bool SourceEntityWalker::visitCallArgName (Identifier Name,
0 commit comments