Skip to content

Commit df82a0f

Browse files
committed
Mark types that we should never see as "unreachable"
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
1 parent b09b9b9 commit df82a0f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/runtime/DynamicCast.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
18011801
return tryCastToErrorExistential;
18021802
}
18031803
swift_runtime_unreachable(
1804-
"Unhandled existential type representation in dynamic cast dispatch");
1804+
"Unknown existential type representation in dynamic cast dispatch");
18051805
}
18061806
case MetadataKind::Metatype:
18071807
return tryCastToMetatype;
@@ -1815,10 +1815,15 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
18151815
// These are internal details of runtime-only structures,
18161816
// so will never appear in compiler-generated types.
18171817
// As such, they don't need support here.
1818+
swift_runtime_unreachable(
1819+
"Unexpected MetadataKind in dynamic cast dispatch");
18181820
return nullptr;
18191821
default:
1822+
// If you see this message, then there is a new MetadataKind that I didn't
1823+
// know about when I wrote this code. Please figure out what it is, how to
1824+
// handle it, and add a case for it.
18201825
swift_runtime_unreachable(
1821-
"Unhandled MetadataKind in dynamic cast dispatch");
1826+
"Unknown MetadataKind in dynamic cast dispatch");
18221827
}
18231828
}
18241829

0 commit comments

Comments
 (0)