Skip to content

Commit aa42045

Browse files
committed
[AST] “Error” types aren’t really unchecked; deal with them explicitly.
1 parent 416d935 commit aa42045

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

include/swift/AST/TypeNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define TYPE_RANGE(Id, First, Last)
8484
#endif
8585

86-
UNCHECKED_TYPE(Error, Type)
86+
TYPE(Error, Type)
8787
UNCHECKED_TYPE(Unresolved, Type)
8888
ABSTRACT_TYPE(Builtin, Type)
8989
BUILTIN_TYPE(BuiltinInteger, BuiltinType)

lib/AST/Type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ TypeBase *TypeBase::getDesugaredType() {
13131313
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
13141314
#define TYPE(id, parent)
13151315
#include "swift/AST/TypeNodes.def"
1316+
case TypeKind::Error:
13161317
case TypeKind::Tuple:
13171318
case TypeKind::Function:
13181319
case TypeKind::GenericFunction:
@@ -1476,6 +1477,7 @@ bool TypeBase::isSpelledLike(Type other) {
14761477
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
14771478
#define TYPE(id, parent)
14781479
#include "swift/AST/TypeNodes.def"
1480+
case TypeKind::Error:
14791481
case TypeKind::Enum:
14801482
case TypeKind::Struct:
14811483
case TypeKind::Class:

lib/IRGen/Fulfillment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static bool isLeafTypeMetadata(CanType type) {
3838
case TypeKind::ID:
3939
#define TYPE(ID, SUPER)
4040
#include "swift/AST/TypeNodes.def"
41+
case TypeKind::Error:
4142
llvm_unreachable("kind is invalid for a canonical type");
4243

4344
#define ARTIFICIAL_TYPE(ID, SUPER) \

lib/IRGen/GenMeta.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,10 @@ namespace {
10051005
llvm::Value *visitInOutType(CanInOutType type) {
10061006
llvm_unreachable("inout type should have been lowered by SILGen");
10071007
}
1008-
1008+
llvm::Value *visitErrorType(CanErrorType type) {
1009+
llvm_unreachable("error type should not appear in IRGen");
1010+
}
1011+
10091012
llvm::Value *visitSILBlockStorageType(CanSILBlockStorageType type) {
10101013
llvm_unreachable("cannot ask for metadata of block storage");
10111014
}

lib/IRGen/GenType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@ TypeCacheEntry TypeConverter::convertType(CanType ty) {
11551155
PrettyStackTraceType stackTrace(IGM.Context, "converting", ty);
11561156

11571157
switch (ty->getKind()) {
1158+
case TypeKind::Error:
1159+
llvm_unreachable("found an ErrorType in IR-gen");
1160+
11581161
#define UNCHECKED_TYPE(id, parent) \
11591162
case TypeKind::id: \
11601163
llvm_unreachable("found a " #id "Type in IR-gen");

lib/SIL/TypeLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ namespace {
230230
RetTy visitInOutType(CanInOutType type) {
231231
llvm_unreachable("shouldn't get an inout type here");
232232
}
233+
RetTy visitErrorType(CanErrorType type) {
234+
llvm_unreachable("shouldn't get an error type here");
235+
}
233236

234237
// Dependent types should be contextualized before visiting.
235238

0 commit comments

Comments
 (0)