Skip to content

Commit b253f94

Browse files
committed
Add CanType::getOptionalObjectType for staging a rename.
In order to replace uses of getAnyOptionalObjectType() with getOptionalObjectType(), we need to update LLDB. But in order to do that, we need to have the version of this function for CanType available. So this adds this, as a temporary measure, to facilitate the LLDB update that will unblock the compiler rename.
1 parent f51d925 commit b253f94

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/swift/AST/Type.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ class CanType : public Type {
391391
static bool isObjCExistentialTypeImpl(CanType type);
392392
static CanType getAnyOptionalObjectTypeImpl(CanType type,
393393
OptionalTypeKind &kind);
394+
static CanType getOptionalObjectTypeImpl(CanType type);
394395
static CanType getReferenceStorageReferentImpl(CanType type);
395396
static CanType getWithoutSpecifierTypeImpl(CanType type);
396397

@@ -457,6 +458,10 @@ class CanType : public Type {
457458
NominalTypeDecl *getAnyNominal() const;
458459
GenericTypeDecl *getAnyGeneric() const;
459460

461+
CanType getOptionalObjectType() const {
462+
return getOptionalObjectTypeImpl(*this);
463+
}
464+
460465
CanType getAnyOptionalObjectType() const {
461466
OptionalTypeKind kind;
462467
return getAnyOptionalObjectTypeImpl(*this, kind);

lib/AST/Type.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,13 @@ CanType CanType::getAnyOptionalObjectTypeImpl(CanType type,
526526
return CanType();
527527
}
528528

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+
529536
Type TypeBase::getAnyPointerElementType(PointerTypeKind &PTK) {
530537
auto &C = getASTContext();
531538
if (auto nominalTy = getAs<NominalType>()) {

0 commit comments

Comments
 (0)