Skip to content

Commit e6bdb60

Browse files
committed
[AST] Add a new isDoubleType accessor to TypeBase
1 parent 4b01c8f commit e6bdb60

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/swift/AST/Types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ class alignas(1 << TypeAlignInBits) TypeBase {
803803
/// Check if this is a CGFloat type from `CoreGraphics` module.
804804
bool isCGFloatType();
805805

806+
/// Check if thih sis a Double type from standard library.
807+
bool isDoubleType();
808+
806809
/// Check if this is either an Array, Set or Dictionary collection type defined
807810
/// at the top level of the Swift module
808811
bool isKnownStdlibCollectionType();

lib/AST/Type.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ bool TypeBase::isCGFloatType() {
829829
NTD->getName().is("CGFloat");
830830
}
831831

832+
bool TypeBase::isDoubleType() {
833+
auto *NTD = getAnyNominal();
834+
return NTD ? NTD->getDecl() == getASTContext().getDoubleDecl() : false;
835+
}
836+
832837
bool TypeBase::isKnownStdlibCollectionType() {
833838
if (auto *structType = getAs<BoundGenericStructType>()) {
834839
auto &ctx = getASTContext();

0 commit comments

Comments
 (0)