Skip to content

Commit a4fb03f

Browse files
committed
runtime: simplify getReflectableConformance()
1 parent acac328 commit a4fb03f

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

stdlib/public/runtime/Reflection.mm

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,12 @@ void swift_MagicMirrorData_summary(const Metadata *T, String *result) {
306306

307307
static std::tuple<const Metadata *, const OpaqueValue *>
308308
getReflectableConformance(const Metadata *T, const OpaqueValue *Value) {
309-
recur:
310309
// If the value is an existential container, look through it to reflect the
311310
// contained value.
312-
switch (T->getKind()) {
313-
case MetadataKind::Tuple:
314-
case MetadataKind::Struct:
315-
case MetadataKind::ForeignClass:
316-
case MetadataKind::ObjCClassWrapper:
317-
case MetadataKind::Class:
318-
case MetadataKind::Opaque:
319-
case MetadataKind::Enum:
320-
case MetadataKind::Optional:
321-
case MetadataKind::Function:
322-
case MetadataKind::Metatype:
323-
break;
324-
325-
case MetadataKind::Existential: {
311+
// TODO: Should look through existential metatypes too, but it doesn't
312+
// really matter yet since we don't have any special mirror behavior for
313+
// concrete metatypes yet.
314+
while (T->getKind() == MetadataKind::Existential) {
326315
auto existential
327316
= static_cast<const ExistentialTypeMetadata *>(T);
328317

@@ -331,22 +320,8 @@ void swift_MagicMirrorData_summary(const Metadata *T, String *result) {
331320
Value = existential->projectValue(Value);
332321

333322
// Existential containers can end up nested in some cases due to generic
334-
// abstraction barriers. Recur in case we have a nested existential.
335-
goto recur;
323+
// abstraction barriers. Repeat in case we have a nested existential.
336324
}
337-
case MetadataKind::ExistentialMetatype:
338-
// TODO: Should look through existential metatypes too, but it doesn't
339-
// really matter yet since we don't have any special mirror behavior for
340-
// concrete metatypes yet.
341-
break;
342-
343-
// Types can't have these kinds.
344-
case MetadataKind::HeapLocalVariable:
345-
case MetadataKind::HeapGenericLocalVariable:
346-
case MetadataKind::ErrorObject:
347-
swift::crash("Swift mirror lookup failure");
348-
}
349-
350325
return std::make_tuple(T, Value);
351326
}
352327

0 commit comments

Comments
 (0)