File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,7 @@ class CanType : public Type {
391
391
static bool isObjCExistentialTypeImpl (CanType type);
392
392
static CanType getAnyOptionalObjectTypeImpl (CanType type,
393
393
OptionalTypeKind &kind);
394
+ static CanType getOptionalObjectTypeImpl (CanType type);
394
395
static CanType getReferenceStorageReferentImpl (CanType type);
395
396
static CanType getWithoutSpecifierTypeImpl (CanType type);
396
397
@@ -457,6 +458,10 @@ class CanType : public Type {
457
458
NominalTypeDecl *getAnyNominal () const ;
458
459
GenericTypeDecl *getAnyGeneric () const ;
459
460
461
+ CanType getOptionalObjectType () const {
462
+ return getOptionalObjectTypeImpl (*this );
463
+ }
464
+
460
465
CanType getAnyOptionalObjectType () const {
461
466
OptionalTypeKind kind;
462
467
return getAnyOptionalObjectTypeImpl (*this , kind);
Original file line number Diff line number Diff line change @@ -526,6 +526,13 @@ CanType CanType::getAnyOptionalObjectTypeImpl(CanType type,
526
526
return CanType ();
527
527
}
528
528
529
+ CanType CanType::getOptionalObjectTypeImpl (CanType type) {
530
+ if (auto boundTy = dyn_cast<BoundGenericEnumType>(type))
531
+ if (boundTy->getDecl ()->classifyAsOptionalType () == OTK_Optional)
532
+ return boundTy.getGenericArgs ()[0 ];
533
+ return CanType ();
534
+ }
535
+
529
536
Type TypeBase::getAnyPointerElementType (PointerTypeKind &PTK) {
530
537
auto &C = getASTContext ();
531
538
if (auto nominalTy = getAs<NominalType>()) {
You can’t perform that action at this time.
0 commit comments