Skip to content

Commit c35d84a

Browse files
committed
[NFC] SubscriptDecl: Replace the const version of getElementTypeLoc with a TypeRepr accessor
1 parent 96bcc7a commit c35d84a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

include/swift/AST/Decl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5647,7 +5647,10 @@ class SubscriptDecl : public GenericContext, public AbstractStorageDecl {
56475647
/// operation.
56485648
Type getElementInterfaceType() const;
56495649
TypeLoc &getElementTypeLoc() { return ElementTy; }
5650-
const TypeLoc &getElementTypeLoc() const { return ElementTy; }
5650+
TypeRepr *getElementTypeRepr() const { return ElementTy.getTypeRepr(); }
5651+
SourceRange getElementTypeSourceRange() const {
5652+
return ElementTy.getSourceRange();
5653+
}
56515654

56525655
/// Determine the kind of Objective-C subscripting this declaration
56535656
/// implies.

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2761,7 +2761,7 @@ OpaqueReturnTypeRepr *ValueDecl::getOpaqueResultTypeRepr() const {
27612761
} else if (auto *FD = dyn_cast<FuncDecl>(this)) {
27622762
returnRepr = FD->getResultTypeRepr();
27632763
} else if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
2764-
returnRepr = SD->getElementTypeLoc().getTypeRepr();
2764+
returnRepr = SD->getElementTypeRepr();
27652765
}
27662766

27672767
return dyn_cast_or_null<OpaqueReturnTypeRepr>(returnRepr);

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ bool swift::isRepresentableInObjC(const SubscriptDecl *SD, ObjCReason Reason) {
927927
if (!IndexResult)
928928
TypeRange = SD->getIndices()->getSourceRange();
929929
else
930-
TypeRange = SD->getElementTypeLoc().getSourceRange();
930+
TypeRange = SD->getElementTypeSourceRange();
931931
SD->diagnose(diag::objc_invalid_on_subscript,
932932
getObjCDiagnosticAttrKind(Reason))
933933
.highlight(TypeRange);

0 commit comments

Comments
 (0)