Skip to content

Commit 541757a

Browse files
committed
AST: Remove TypeBase::isOpenedExistential()
At one point, OpenedArchetypeType did not exist as a separate subclass of ArchetypeType, so this method did something. Now, it's just equivalent to calling is<> or isa<>. I also removed a couple of asserts that were obvious no-ops as a result.
1 parent 35f79e4 commit 541757a

File tree

7 files changed

+8
-31
lines changed

7 files changed

+8
-31
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,6 @@ class alignas(1 << TypeAlignInBits) TypeBase
792792
return getRecursiveProperties().hasOpaqueArchetype();
793793
}
794794

795-
/// Determine whether the type is an opened existential type.
796-
///
797-
/// To determine whether there is an opened existential type
798-
/// anywhere in the type, use \c hasOpenedExistential.
799-
bool isOpenedExistential() const;
800-
801795
/// Determine whether the type is an opened existential type with Error inside
802796
bool isOpenedExistentialWithError();
803797

@@ -7932,14 +7926,6 @@ inline bool TypeBase::isClassExistentialType() {
79327926
return false;
79337927
}
79347928

7935-
inline bool TypeBase::isOpenedExistential() const {
7936-
if (!hasOpenedExistential())
7937-
return false;
7938-
7939-
CanType T = getCanonicalType();
7940-
return isa<OpenedArchetypeType>(T);
7941-
}
7942-
79437929
inline bool TypeBase::canDynamicallyBeOptionalType(bool includeExistential) {
79447930
CanType T = getCanonicalType();
79457931
auto isArchetypeOrExistential = isa<ArchetypeType>(T) ||

include/swift/SIL/SILType.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,6 @@ class SILType {
452452
return getASTType()->isClassExistentialType();
453453
}
454454

455-
/// Returns true if the referenced type is an opened existential type
456-
/// (which is actually a kind of archetype).
457-
bool isOpenedExistential() const {
458-
return getASTType()->isOpenedExistential();
459-
}
460-
461455
/// Returns true if the referenced type is expressed in terms of one
462456
/// or more opened existential archetypes.
463457
bool hasOpenedExistential() const {

lib/SIL/Utils/MemoryLocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ bool MemoryLocations::analyzeAddrProjection(
436436
// open_existential_addr).
437437
if (!isa<OpenExistentialAddrInst>(loc->representativeValue))
438438
return false;
439-
assert(loc->representativeValue->getType().isOpenedExistential());
439+
assert(loc->representativeValue->getType().is<OpenedArchetypeType>());
440440
loc->representativeValue = projection;
441441
}
442442
}

lib/SILGen/SILGenExpr.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,13 +3204,12 @@ emitKeyPathRValueBase(SILGenFunction &subSGF,
32043204
if (baseType->isAnyExistentialType()) {
32053205
// Use the opened archetype from the AST for a protocol member, or make a
32063206
// new one (which we'll upcast immediately below) for a class member.
3207-
ArchetypeType *opened;
3207+
OpenedArchetypeType *opened;
32083208
if (storage->getDeclContext()->getSelfClassDecl()) {
32093209
opened = OpenedArchetypeType::get(baseType);
32103210
} else {
3211-
opened = subs.getReplacementTypes()[0]->castTo<ArchetypeType>();
3211+
opened = subs.getReplacementTypes()[0]->castTo<OpenedArchetypeType>();
32123212
}
3213-
assert(opened->isOpenedExistential());
32143213

32153214
FormalEvaluationScope scope(subSGF);
32163215

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

36583657
// Open an existential lvalue, if necessary.
36593658
if (baseType->isAnyExistentialType()) {
3660-
auto opened = subs.getReplacementTypes()[0]->castTo<ArchetypeType>();
3661-
assert(opened->isOpenedExistential());
3659+
auto opened = subs.getReplacementTypes()[0]->castTo<OpenedArchetypeType>();
36623660
baseType = opened->getCanonicalType();
36633661
lv = subSGF.emitOpenExistentialLValue(loc, std::move(lv),
36643662
CanArchetypeType(opened),

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ SILCombiner::buildConcreteOpenedExistentialInfoFromSoleConformingType(
802802
/// and that the protocol type has a sole conformance, then we can propagate
803803
/// concrete type for it as well.
804804
ArchetypeType *archetypeTy;
805-
if (SwiftArgType->isOpenedExistential() &&
805+
if (isa<OpenedArchetypeType>(SwiftArgType) &&
806806
(archetypeTy = dyn_cast<ArchetypeType>(SwiftArgType)) &&
807807
(archetypeTy->getConformsTo().size() == 1)) {
808808
PD = archetypeTy->getConformsTo()[0];
@@ -1116,7 +1116,7 @@ SILValue SILCombiner::canCastArg(FullApplySite Apply,
11161116
const OpenedArchetypeInfo &OAI,
11171117
const ConcreteExistentialInfo &CEI,
11181118
unsigned ArgIdx) {
1119-
if (!CEI.ConcreteValue || CEI.ConcreteType->isOpenedExistential() ||
1119+
if (!CEI.ConcreteValue || isa<OpenedArchetypeType>(CEI.ConcreteType) ||
11201120
!CEI.ConcreteValue->getType().isAddress())
11211121
return SILValue();
11221122

@@ -1378,7 +1378,7 @@ SILCombiner::propagateConcreteTypeOfInitExistential(FullApplySite Apply,
13781378

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

13841384
// Try to derive the concrete type and the related conformance of self and

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ SILInstruction *SILCombiner::visitAllocStackInst(AllocStackInst *AS) {
655655
// their definitions.
656656
if (IEI && !OEI &&
657657
!IEI->getLoweredConcreteType().hasOpenedExistential()) {
658-
assert(!IEI->getLoweredConcreteType().isOpenedExistential());
659658
Builder.setCurrentDebugScope(AS->getDebugScope());
660659
auto varInfo = AS->getVarInfo();
661660
if (varInfo) {

lib/SILOptimizer/Utils/Existential.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void ConcreteExistentialInfo::initializeSubstitutionMap(
285285
/// ConcreteTypeDef to the definition of that type.
286286
void ConcreteExistentialInfo::initializeConcreteTypeDef(
287287
SILInstruction *typeConversionInst) {
288-
if (!ConcreteType->isOpenedExistential())
288+
if (!isa<OpenedArchetypeType>(ConcreteType))
289289
return;
290290

291291
assert(isValid());

0 commit comments

Comments
 (0)