Skip to content

Commit

Permalink
Mark types that we should never see as "unreachable"
Browse files Browse the repository at this point in the history
Clarify the unreachable messaging a bit:
* "Unexpected" means I knew about it but thought it could
  never appear here
* "Unknown" means I didn't know about it when I wrote this code
  • Loading branch information
tbkka committed Aug 26, 2020
1 parent b09b9b9 commit df82a0f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions stdlib/public/runtime/DynamicCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
return tryCastToErrorExistential;
}
swift_runtime_unreachable(
"Unhandled existential type representation in dynamic cast dispatch");
"Unknown existential type representation in dynamic cast dispatch");
}
case MetadataKind::Metatype:
return tryCastToMetatype;
Expand All @@ -1815,10 +1815,15 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
// These are internal details of runtime-only structures,
// so will never appear in compiler-generated types.
// As such, they don't need support here.
swift_runtime_unreachable(
"Unexpected MetadataKind in dynamic cast dispatch");
return nullptr;
default:
// If you see this message, then there is a new MetadataKind that I didn't
// know about when I wrote this code. Please figure out what it is, how to
// handle it, and add a case for it.
swift_runtime_unreachable(
"Unhandled MetadataKind in dynamic cast dispatch");
"Unknown MetadataKind in dynamic cast dispatch");
}
}

Expand Down

0 comments on commit df82a0f

Please sign in to comment.