Runtime: Tolerate unknown metadata kinds.

We want to be able to potentially introduce new metadata kinds in future Swift compilers, so a runtime ought to be able to degrade gracefully in the face of metadata kinds it doesn't know about. Remove attempts to exhaustively switch over metadata kinds and instead treat unknown metadata kinds as opaque.
This commit is contained in:
Joe Groff
2018-05-17 15:35:06 -07:00
parent 812e94587e
commit 681a96b45c
12 changed files with 70 additions and 391 deletions

View File

@@ -194,32 +194,10 @@ void _swift_makeAnyHashableUpcastingToHashableBaseType(
return;
}
case MetadataKind::Struct:
case MetadataKind::Enum:
case MetadataKind::Optional:
default:
_swift_makeAnyHashableUsingDefaultRepresentation(
value, anyHashableResultPointer, type, hashableWT);
return;
case MetadataKind::ErrorObject:
// ErrorObject metadata is not used for any Swift-level values, so
// this case is unreachable.
_failCorruptType(type);
case MetadataKind::Opaque:
case MetadataKind::Tuple:
case MetadataKind::Function:
case MetadataKind::Existential:
case MetadataKind::Metatype:
case MetadataKind::ExistentialMetatype:
case MetadataKind::HeapLocalVariable:
case MetadataKind::HeapGenericLocalVariable:
// We assume that the value can not be an existential,
// because existentials can't conform to Hashable today.
//
// FIXME: handle generalized existentials when Swift has them.
_failCorruptType(type);
}
_failCorruptType(type);
}