Skip to content

[Sema] NFC: Use exhaustive switches in coerceToType() #22709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions lib/Sema/CSApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6677,7 +6677,24 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
break;
}

default:
#define SUGARED_TYPE(Name, Parent) case TypeKind::Name:
#define BUILTIN_TYPE(Name, Parent) case TypeKind::Name:
#define UNCHECKED_TYPE(Name, Parent) case TypeKind::Name:
#define ARTIFICIAL_TYPE(Name, Parent) case TypeKind::Name:
#define TYPE(Name, Parent)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
case TypeKind::InOut:
case TypeKind::Module:
case TypeKind::Enum:
case TypeKind::Struct:
case TypeKind::Protocol:
case TypeKind::ProtocolComposition:
case TypeKind::BoundGenericEnum:
case TypeKind::BoundGenericStruct:
case TypeKind::GenericFunction:
case TypeKind::GenericTypeParam:
case TypeKind::DependentMember:
break;
}

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

// Coercion to Optional<T>.
Expand All @@ -6709,9 +6726,32 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
diagnoseOptionalInjection(result);
return result;
}
}

default:
#define SUGARED_TYPE(Name, Parent) case TypeKind::Name:
#define BUILTIN_TYPE(Name, Parent) case TypeKind::Name:
#define UNCHECKED_TYPE(Name, Parent) case TypeKind::Name:
#define ARTIFICIAL_TYPE(Name, Parent) case TypeKind::Name:
#define TYPE(Name, Parent)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
case TypeKind::Module:
case TypeKind::Tuple:
case TypeKind::Enum:
case TypeKind::Struct:
case TypeKind::Class:
case TypeKind::BoundGenericClass:
case TypeKind::BoundGenericStruct:
case TypeKind::Metatype:
case TypeKind::DynamicSelf:
case TypeKind::PrimaryArchetype:
case TypeKind::OpenedArchetype:
case TypeKind::NestedArchetype:
case TypeKind::GenericTypeParam:
case TypeKind::DependentMember:
case TypeKind::Function:
case TypeKind::GenericFunction:
case TypeKind::LValue:
case TypeKind::InOut:
break;
}

Expand Down