@@ -330,9 +330,13 @@ class DeclRefTypeRepr : public TypeRepr {
330330 explicit DeclRefTypeRepr (TypeReprKind K) : TypeRepr(K) {}
331331
332332public:
333- // / Returns \c this if it is a \c IdentTypeRepr. Otherwise, \c this
334- // / is a \c MemberTypeRepr, and the method returns its base component.
335- TypeRepr *getBaseComponent ();
333+ // / Returns the root qualifier. For example, `A` for `A.B.C`. The root
334+ // / qualifier of a `IdentTypeRepr` is itself.
335+ TypeRepr *getRoot ();
336+
337+ // / Returns the root qualifier. For example, `A` for `A.B.C`. The root
338+ // / qualifier of a `IdentTypeRepr` is itself.
339+ const TypeRepr *getRoot () const ;
336340
337341 // / Returns \c this if it is a \c IdentTypeRepr. Otherwise, \c this
338342 // / is a \c MemberTypeRepr, and the method returns its last member component.
@@ -498,11 +502,11 @@ class MemberTypeRepr final : public DeclRefTypeRepr,
498502 private llvm::TrailingObjects<MemberTypeRepr, IdentTypeRepr *> {
499503 friend TrailingObjects;
500504
501- // / The base component, which is not necessarily an identifier type.
502- TypeRepr *Base ;
505+ // / The root component, which is not necessarily an identifier type.
506+ TypeRepr *Root ;
503507
504- MemberTypeRepr (TypeRepr *Base , ArrayRef<IdentTypeRepr *> MemberComponents)
505- : DeclRefTypeRepr(TypeReprKind::Member), Base(Base ) {
508+ MemberTypeRepr (TypeRepr *Root , ArrayRef<IdentTypeRepr *> MemberComponents)
509+ : DeclRefTypeRepr(TypeReprKind::Member), Root(Root ) {
506510 Bits.MemberTypeRepr .NumMemberComponents = MemberComponents.size ();
507511 assert (MemberComponents.size () > 0 &&
508512 " MemberTypeRepr requires at least 1 member component" );
@@ -511,13 +515,14 @@ class MemberTypeRepr final : public DeclRefTypeRepr,
511515 }
512516
513517public:
514- static TypeRepr *create (const ASTContext &Ctx, TypeRepr *Base ,
518+ static TypeRepr *create (const ASTContext &Ctx, TypeRepr *Root ,
515519 ArrayRef<IdentTypeRepr *> MemberComponents);
516520
517521 static DeclRefTypeRepr *create (const ASTContext &Ctx,
518522 ArrayRef<IdentTypeRepr *> Components);
519523
520- TypeRepr *getBaseComponent () const { return Base; }
524+ // / Returns the root qualifier. For example, `A` for `A.B.C`.
525+ TypeRepr *getRoot () const { return Root; }
521526
522527 ArrayRef<IdentTypeRepr *> getMemberComponents () const {
523528 return {getTrailingObjects<IdentTypeRepr *>(),
@@ -534,9 +539,7 @@ class MemberTypeRepr final : public DeclRefTypeRepr,
534539 static bool classof (const MemberTypeRepr *T) { return true ; }
535540
536541private:
537- SourceLoc getStartLocImpl () const {
538- return getBaseComponent ()->getStartLoc ();
539- }
542+ SourceLoc getStartLocImpl () const { return getRoot ()->getStartLoc (); }
540543 SourceLoc getEndLocImpl () const { return getLastComponent ()->getEndLoc (); }
541544 SourceLoc getLocImpl () const { return getLastComponent ()->getLoc (); }
542545
0 commit comments