Skip to content

AST: Remove TypeBase::isOpenedExistential() #79659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
return getRecursiveProperties().hasOpaqueArchetype();
}

/// Determine whether the type is an opened existential type.
///
/// To determine whether there is an opened existential type
/// anywhere in the type, use \c hasOpenedExistential.
bool isOpenedExistential() const;

/// Determine whether the type is an opened existential type with Error inside
bool isOpenedExistentialWithError();

Expand Down Expand Up @@ -7932,14 +7926,6 @@ inline bool TypeBase::isClassExistentialType() {
return false;
}

inline bool TypeBase::isOpenedExistential() const {
if (!hasOpenedExistential())
return false;

CanType T = getCanonicalType();
return isa<OpenedArchetypeType>(T);
}

inline bool TypeBase::canDynamicallyBeOptionalType(bool includeExistential) {
CanType T = getCanonicalType();
auto isArchetypeOrExistential = isa<ArchetypeType>(T) ||
Expand Down
6 changes: 0 additions & 6 deletions include/swift/SIL/SILType.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,6 @@ class SILType {
return getASTType()->isClassExistentialType();
}

/// Returns true if the referenced type is an opened existential type
/// (which is actually a kind of archetype).
bool isOpenedExistential() const {
return getASTType()->isOpenedExistential();
}

/// Returns true if the referenced type is expressed in terms of one
/// or more opened existential archetypes.
bool hasOpenedExistential() const {
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/Utils/MemoryLocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ bool MemoryLocations::analyzeAddrProjection(
// open_existential_addr).
if (!isa<OpenExistentialAddrInst>(loc->representativeValue))
return false;
assert(loc->representativeValue->getType().isOpenedExistential());
assert(loc->representativeValue->getType().is<OpenedArchetypeType>());
loc->representativeValue = projection;
}
}
Expand Down
8 changes: 3 additions & 5 deletions lib/SILGen/SILGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3204,13 +3204,12 @@ emitKeyPathRValueBase(SILGenFunction &subSGF,
if (baseType->isAnyExistentialType()) {
// Use the opened archetype from the AST for a protocol member, or make a
// new one (which we'll upcast immediately below) for a class member.
ArchetypeType *opened;
OpenedArchetypeType *opened;
if (storage->getDeclContext()->getSelfClassDecl()) {
opened = OpenedArchetypeType::get(baseType);
} else {
opened = subs.getReplacementTypes()[0]->castTo<ArchetypeType>();
opened = subs.getReplacementTypes()[0]->castTo<OpenedArchetypeType>();
}
assert(opened->isOpenedExistential());

FormalEvaluationScope scope(subSGF);

Expand Down Expand Up @@ -3657,8 +3656,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,

// Open an existential lvalue, if necessary.
if (baseType->isAnyExistentialType()) {
auto opened = subs.getReplacementTypes()[0]->castTo<ArchetypeType>();
assert(opened->isOpenedExistential());
auto opened = subs.getReplacementTypes()[0]->castTo<OpenedArchetypeType>();
baseType = opened->getCanonicalType();
lv = subSGF.emitOpenExistentialLValue(loc, std::move(lv),
CanArchetypeType(opened),
Expand Down
6 changes: 3 additions & 3 deletions lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ SILCombiner::buildConcreteOpenedExistentialInfoFromSoleConformingType(
/// and that the protocol type has a sole conformance, then we can propagate
/// concrete type for it as well.
ArchetypeType *archetypeTy;
if (SwiftArgType->isOpenedExistential() &&
if (isa<OpenedArchetypeType>(SwiftArgType) &&
(archetypeTy = dyn_cast<ArchetypeType>(SwiftArgType)) &&
(archetypeTy->getConformsTo().size() == 1)) {
PD = archetypeTy->getConformsTo()[0];
Expand Down Expand Up @@ -1116,7 +1116,7 @@ SILValue SILCombiner::canCastArg(FullApplySite Apply,
const OpenedArchetypeInfo &OAI,
const ConcreteExistentialInfo &CEI,
unsigned ArgIdx) {
if (!CEI.ConcreteValue || CEI.ConcreteType->isOpenedExistential() ||
if (!CEI.ConcreteValue || isa<OpenedArchetypeType>(CEI.ConcreteType) ||
!CEI.ConcreteValue->getType().isAddress())
return SILValue();

Expand Down Expand Up @@ -1378,7 +1378,7 @@ SILCombiner::propagateConcreteTypeOfInitExistential(FullApplySite Apply,

// If the lookup type is not an opened existential type,
// it cannot be made more concrete.
if (!WMI->getLookupType()->isOpenedExistential())
if (!isa<OpenedArchetypeType>(WMI->getLookupType()))
return nullptr;

// Try to derive the concrete type and the related conformance of self and
Expand Down
1 change: 0 additions & 1 deletion lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
// their definitions.
if (IEI && !OEI &&
!IEI->getLoweredConcreteType().hasOpenedExistential()) {
assert(!IEI->getLoweredConcreteType().isOpenedExistential());
Builder.setCurrentDebugScope(AS->getDebugScope());
auto varInfo = AS->getVarInfo();
if (varInfo) {
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Utils/Existential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void ConcreteExistentialInfo::initializeSubstitutionMap(
/// ConcreteTypeDef to the definition of that type.
void ConcreteExistentialInfo::initializeConcreteTypeDef(
SILInstruction *typeConversionInst) {
if (!ConcreteType->isOpenedExistential())
if (!isa<OpenedArchetypeType>(ConcreteType))
return;

assert(isValid());
Expand Down