Skip to content

Commit 3861c0e

Browse files
authored
Merge pull request #22709 from davezarzycki/exhaustive_coerceToType
[Sema] NFC: Use exhaustive switches in coerceToType()
2 parents 17e64f5 + 9926bae commit 3861c0e

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

lib/Sema/CSApply.cpp

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6677,7 +6677,24 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
66776677
break;
66786678
}
66796679

6680-
default:
6680+
#define SUGARED_TYPE(Name, Parent) case TypeKind::Name:
6681+
#define BUILTIN_TYPE(Name, Parent) case TypeKind::Name:
6682+
#define UNCHECKED_TYPE(Name, Parent) case TypeKind::Name:
6683+
#define ARTIFICIAL_TYPE(Name, Parent) case TypeKind::Name:
6684+
#define TYPE(Name, Parent)
6685+
#include "swift/AST/TypeNodes.def"
6686+
case TypeKind::Error:
6687+
case TypeKind::InOut:
6688+
case TypeKind::Module:
6689+
case TypeKind::Enum:
6690+
case TypeKind::Struct:
6691+
case TypeKind::Protocol:
6692+
case TypeKind::ProtocolComposition:
6693+
case TypeKind::BoundGenericEnum:
6694+
case TypeKind::BoundGenericStruct:
6695+
case TypeKind::GenericFunction:
6696+
case TypeKind::GenericTypeParam:
6697+
case TypeKind::DependentMember:
66816698
break;
66826699
}
66836700

@@ -6687,7 +6704,7 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
66876704
// Coercions from a type to an existential type.
66886705
case TypeKind::ExistentialMetatype:
66896706
case TypeKind::ProtocolComposition:
6690-
case TypeKind::Protocol: {
6707+
case TypeKind::Protocol:
66916708
return coerceExistential(expr, toType, locator);
66926709

66936710
// Coercion to Optional<T>.
@@ -6709,9 +6726,32 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
67096726
diagnoseOptionalInjection(result);
67106727
return result;
67116728
}
6712-
}
67136729

6714-
default:
6730+
#define SUGARED_TYPE(Name, Parent) case TypeKind::Name:
6731+
#define BUILTIN_TYPE(Name, Parent) case TypeKind::Name:
6732+
#define UNCHECKED_TYPE(Name, Parent) case TypeKind::Name:
6733+
#define ARTIFICIAL_TYPE(Name, Parent) case TypeKind::Name:
6734+
#define TYPE(Name, Parent)
6735+
#include "swift/AST/TypeNodes.def"
6736+
case TypeKind::Error:
6737+
case TypeKind::Module:
6738+
case TypeKind::Tuple:
6739+
case TypeKind::Enum:
6740+
case TypeKind::Struct:
6741+
case TypeKind::Class:
6742+
case TypeKind::BoundGenericClass:
6743+
case TypeKind::BoundGenericStruct:
6744+
case TypeKind::Metatype:
6745+
case TypeKind::DynamicSelf:
6746+
case TypeKind::PrimaryArchetype:
6747+
case TypeKind::OpenedArchetype:
6748+
case TypeKind::NestedArchetype:
6749+
case TypeKind::GenericTypeParam:
6750+
case TypeKind::DependentMember:
6751+
case TypeKind::Function:
6752+
case TypeKind::GenericFunction:
6753+
case TypeKind::LValue:
6754+
case TypeKind::InOut:
67156755
break;
67166756
}
67176757

0 commit comments

Comments
 (0)