Skip to content

Commit aaaded5

Browse files
committed
AST: Remove TypeBase::isEmptyExistentialComposition()
This is made redundant by TypeBase::isAny().
1 parent 3eabc21 commit aaaded5

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
916916

917917
/// Whether this is the AnyObject type.
918918
bool isAnyObject();
919-
920-
/// Whether this is an empty existential composition ("{}").
921-
bool isEmptyExistentialComposition();
922919

923920
/// Whether this is an existential composition containing
924921
/// Error.

lib/AST/Type.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -659,17 +659,6 @@ bool TypeBase::isAnyObject() {
659659
return false;
660660
}
661661

662-
bool TypeBase::isEmptyExistentialComposition() {
663-
if (auto emtType = ExistentialMetatypeType::get(this)) {
664-
if (auto pcType = emtType->getInstanceType()->
665-
getAs<ProtocolCompositionType>()) {
666-
return pcType->getProtocols().empty();
667-
}
668-
}
669-
670-
return false;
671-
}
672-
673662
bool TypeBase::isExistentialWithError() {
674663
// FIXME: Compute this as a bit in TypeBase so this operation isn't
675664
// overly expensive.

lib/Sema/CSRanking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static bool hasEmptyExistentialParameterMismatch(ValueDecl *decl1,
392392
return false;
393393

394394
if (t2->isAnyExistentialType() && !t1->isAnyExistentialType())
395-
return t2->isEmptyExistentialComposition();
395+
return t2->isAny();
396396
}
397397
return false;
398398
}

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ matchCallArguments(ConstraintSystem &cs, ConstraintKind kind,
646646

647647
// In the empty existential parameter case,
648648
// it's sufficient to simply match call arguments.
649-
if (paramType->isEmptyExistentialComposition()) {
649+
if (paramType->isAny()) {
650650
// Argument of the existential type can't be inout.
651651
if (argType->is<InOutType>())
652652
return ConstraintSystem::SolutionKind::Error;
@@ -1124,7 +1124,7 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
11241124
return SolutionKind::Error;
11251125

11261126
// Conformance to 'Any' always holds.
1127-
if (type2->isEmptyExistentialComposition())
1127+
if (type2->isAny())
11281128
return SolutionKind::Solved;
11291129

11301130
// If the first type is a type variable or member thereof, there's nothing
@@ -1326,7 +1326,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
13261326

13271327
// For symmetry with overload resolution, penalize conversions to empty
13281328
// existentials.
1329-
if (type2->isEmptyExistentialComposition())
1329+
if (type2->isAny())
13301330
increaseScore(ScoreKind::SK_EmptyExistentialConversion);
13311331

13321332
return SolutionKind::Solved;

0 commit comments

Comments
 (0)