Skip to content

Commit 7f9e322

Browse files
jckartergottesmm
authored andcommitted
[+0-all-args] Knock out some inappropriate "unreachable"s in the runtime.
Future Swifts may add new metadata kinds, so it isn't appropriate to crash when we see one. In the case of reflection, we can fall back to opaque behavior. rdar://34222540
1 parent f6ec0f0 commit 7f9e322

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

stdlib/public/runtime/ReflectionMirror.mm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,20 @@ auto call(OpaqueValue *passedValue, const Metadata *T, const Metadata *passedTyp
635635

636636
/// TODO: Implement specialized mirror witnesses for all kinds.
637637
case MetadataKind::Function:
638-
case MetadataKind::Existential: {
639-
OpaqueImpl impl;
640-
return call(&impl);
641-
}
638+
case MetadataKind::Existential:
639+
break;
642640

643641
// Types can't have these kinds.
644642
case MetadataKind::HeapLocalVariable:
645643
case MetadataKind::HeapGenericLocalVariable:
646644
case MetadataKind::ErrorObject:
647645
swift::crash("Swift mirror lookup failure");
648-
}
646+
}
649647

650-
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
648+
// If we have an unknown kind of type, or a type without special handling,
649+
// treat it as opaque.
650+
OpaqueImpl impl;
651+
return call(&impl);
651652
}
652653

653654
} // end anonymous namespace
@@ -738,7 +739,7 @@ char swift_reflectionMirror_displayStyle(OpaqueValue *value, const Metadata *T)
738739
return "(ErrorType Object)";
739740
}
740741

741-
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
742+
return "(Unknown)";
742743
}
743744

744745
#if SWIFT_OBJC_INTEROP

0 commit comments

Comments
 (0)