Skip to content

Commit 14f6dc9

Browse files
committed
AST: Clean up TypeBase::isOpenedExistentialWithError()
1 parent cf598a2 commit 14f6dc9

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
@@ -6685,17 +6685,6 @@ inline bool TypeBase::isOpenedExistential() const {
66856685
return isa<OpenedArchetypeType>(T);
66866686
}
66876687

6688-
inline bool TypeBase::isOpenedExistentialWithError() {
6689-
if (!hasOpenedExistential())
6690-
return false;
6691-
6692-
CanType T = getCanonicalType();
6693-
if (auto archetype = dyn_cast<OpenedArchetypeType>(T)) {
6694-
return archetype->getExistentialType()->isExistentialWithError();
6695-
}
6696-
return false;
6697-
}
6698-
66996688
inline bool TypeBase::canDynamicallyBeOptionalType(bool includeExistential) {
67006689
CanType T = getCanonicalType();
67016690
auto isArchetypeOrExistential = isa<ArchetypeType>(T) ||

lib/AST/Type.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,19 @@ bool TypeBase::isExistentialWithError() {
11071107
return layout.isExistentialWithError(getASTContext());
11081108
}
11091109

1110+
bool TypeBase::isOpenedExistentialWithError() {
1111+
if (auto archetype = getAs<OpenedArchetypeType>()) {
1112+
auto errorProto = getASTContext().getErrorDecl();
1113+
if (!errorProto) return false;
1114+
1115+
for (auto protoDecl : archetype->getConformsTo()) {
1116+
if (protoDecl == errorProto || protoDecl->inheritsFrom(errorProto))
1117+
return true;
1118+
}
1119+
}
1120+
return false;
1121+
}
1122+
11101123
bool TypeBase::isStdlibType() {
11111124
if (auto *NTD = getAnyNominal()) {
11121125
auto *DC = NTD->getDeclContext();

0 commit comments

Comments
 (0)