@@ -70,8 +70,7 @@ class SemaAnnotator : public ASTWalker {
7070 bool passReference (ModuleEntity Mod, std::pair<Identifier, SourceLoc> IdLoc);
7171
7272 bool passSubscriptReference (ValueDecl *D, SourceLoc Loc,
73- Optional<AccessKind> AccKind,
74- bool IsOpenBracket);
73+ ReferenceMetaData Data, bool IsOpenBracket);
7574
7675 bool passCallArgNames (Expr *Fn, TupleExpr *TupleE);
7776
@@ -265,6 +264,8 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
265264 !isa<MakeTemporarilyEscapableExpr>(E) &&
266265 !isa<CollectionUpcastConversionExpr>(E) &&
267266 !isa<OpaqueValueExpr>(E) &&
267+ !isa<SubscriptExpr>(E) &&
268+ !isa<KeyPathExpr>(E) &&
268269 E->isImplicit ())
269270 return { true , E };
270271
@@ -326,16 +327,19 @@ std::pair<bool, Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
326327 if (SE->hasDecl ())
327328 SubscrD = SE->getDecl ().getDecl ();
328329
330+ ReferenceMetaData data (SemaReferenceKind::SubscriptRef, OpAccess,
331+ SE->isImplicit ());
332+
329333 if (SubscrD) {
330- if (!passSubscriptReference (SubscrD, E->getLoc (), OpAccess , true ))
334+ if (!passSubscriptReference (SubscrD, E->getLoc (), data , true ))
331335 return { false , nullptr };
332336 }
333337
334338 if (!SE->getIndex ()->walk (*this ))
335339 return { false , nullptr };
336340
337341 if (SubscrD) {
338- if (!passSubscriptReference (SubscrD, E->getEndLoc (), OpAccess , false ))
342+ if (!passSubscriptReference (SubscrD, E->getEndLoc (), data , false ))
339343 return { false , nullptr };
340344 }
341345
@@ -577,14 +581,14 @@ bool SemaAnnotator::passModulePathElements(
577581}
578582
579583bool SemaAnnotator::passSubscriptReference (ValueDecl *D, SourceLoc Loc,
580- Optional<AccessKind> AccKind ,
584+ ReferenceMetaData Data ,
581585 bool IsOpenBracket) {
582586 CharSourceRange Range = Loc.isValid ()
583587 ? CharSourceRange (Loc, 1 )
584588 : CharSourceRange ();
585589
586- bool Continue = SEWalker. visitSubscriptReference (D, Range, AccKind,
587- IsOpenBracket);
590+ bool Continue =
591+ SEWalker. visitSubscriptReference (D, Range, Data, IsOpenBracket);
588592 if (!Continue)
589593 Cancelled = true ;
590594 return Continue;
@@ -727,13 +731,14 @@ bool SourceEntityWalker::visitDeclReference(ValueDecl *D, CharSourceRange Range,
727731
728732bool SourceEntityWalker::visitSubscriptReference (ValueDecl *D,
729733 CharSourceRange Range,
730- Optional<AccessKind> AccKind ,
734+ ReferenceMetaData Data ,
731735 bool IsOpenBracket) {
732736 // Most of the clients treat subscript reference the same way as a
733737 // regular reference when called on the open bracket and
734738 // 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 ;
737742}
738743
739744bool SourceEntityWalker::visitCallArgName (Identifier Name,
0 commit comments