Skip to content

Commit a85bb5a

Browse files
committed
AST: Clean up TypeBase::isOpenedExistentialWithError()
1 parent 16a84fc commit a85bb5a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6689,17 +6689,6 @@ inline bool TypeBase::isOpenedExistential() const {
66896689
return isa<OpenedArchetypeType>(T);
66906690
}
66916691

6692-
inline bool TypeBase::isOpenedExistentialWithError() {
6693-
if (!hasOpenedExistential())
6694-
return false;
6695-
6696-
CanType T = getCanonicalType();
6697-
if (auto archetype = dyn_cast<OpenedArchetypeType>(T)) {
6698-
return archetype->getExistentialType()->isExistentialWithError();
6699-
}
6700-
return false;
6701-
}
6702-
67036692
inline bool TypeBase::canDynamicallyBeOptionalType(bool includeExistential) {
67046693
CanType T = getCanonicalType();
67056694
auto isArchetypeOrExistential = isa<ArchetypeType>(T) ||

lib/AST/Type.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,19 @@ bool TypeBase::isExistentialWithError() {
11131113
return layout.isExistentialWithError(getASTContext());
11141114
}
11151115

1116+
bool TypeBase::isOpenedExistentialWithError() {
1117+
if (auto archetype = getAs<OpenedArchetypeType>()) {
1118+
auto errorProto = getASTContext().getErrorDecl();
1119+
if (!errorProto) return false;
1120+
1121+
for (auto protoDecl : archetype->getConformsTo()) {
1122+
if (protoDecl == errorProto || protoDecl->inheritsFrom(errorProto))
1123+
return true;
1124+
}
1125+
}
1126+
return false;
1127+
}
1128+
11161129
bool TypeBase::isStdlibType() {
11171130
if (auto *NTD = getAnyNominal()) {
11181131
auto *DC = NTD->getDeclContext();

0 commit comments

Comments
 (0)