File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -795,6 +795,9 @@ class alignas(1 << TypeAlignInBits) TypeBase {
795
795
// / Check if this type is equal to Swift.Bool.
796
796
bool isBool ();
797
797
798
+ // / Check if this type is equal to Swift.Optional.
799
+ bool isOptional ();
800
+
798
801
// / Check if this type is equal to Builtin.IntN.
799
802
bool isBuiltinIntegerType (unsigned bitWidth);
800
803
Original file line number Diff line number Diff line change @@ -628,6 +628,16 @@ bool TypeBase::isBool() {
628
628
return false ;
629
629
}
630
630
631
+ // / Check if this type is equal to Swift.Bool.
632
+ bool TypeBase::isOptional () {
633
+ if (auto generic = getAnyGeneric ()) {
634
+ if (isa<EnumDecl>(generic)) {
635
+ return getASTContext ().getOptionalDecl () == generic;
636
+ }
637
+ }
638
+ return false ;
639
+ }
640
+
631
641
Type TypeBase::getRValueType () {
632
642
// If the type is not an lvalue, this is a no-op.
633
643
if (!hasLValueType ())
You can’t perform that action at this time.
0 commit comments