File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -3484,22 +3484,23 @@ ExistentialMetatypeValueWitnessTableCacheEntry(unsigned numWitnessTables) {
3484
3484
SWIFT_RUNTIME_EXPORT
3485
3485
const ExistentialMetatypeMetadata *
3486
3486
swift::swift_getExistentialMetatypeMetadata (const Metadata *instanceMetadata) {
3487
- if (instanceMetadata->getKind () != MetadataKind::Existential
3488
- && instanceMetadata->getKind () != MetadataKind::ExistentialMetatype)
3489
- return nullptr ;
3490
-
3491
3487
return &ExistentialMetatypes.getOrInsert (instanceMetadata).first ->Data ;
3492
3488
}
3493
3489
3494
3490
ExistentialMetatypeCacheEntry::ExistentialMetatypeCacheEntry (
3495
3491
const Metadata *instanceMetadata) {
3496
3492
ExistentialTypeFlags flags;
3497
- if (instanceMetadata->getKind () == MetadataKind::Existential) {
3493
+ switch (instanceMetadata->getKind ()) {
3494
+ case MetadataKind::Existential:
3498
3495
flags = static_cast <const ExistentialTypeMetadata*>(instanceMetadata)
3499
3496
->Flags ;
3500
- } else {
3497
+ break ;
3498
+ case MetadataKind::ExistentialMetatype:
3501
3499
flags = static_cast <const ExistentialMetatypeMetadata*>(instanceMetadata)
3502
3500
->Flags ;
3501
+ break ;
3502
+ default :
3503
+ assert (false && " expected existential metadata" );
3503
3504
}
3504
3505
3505
3506
Data.setKind (MetadataKind::ExistentialMetatype);
Original file line number Diff line number Diff line change @@ -1446,13 +1446,13 @@ class DecodedMetadataBuilder {
1446
1446
TypeLookupErrorOr<BuiltType> createExistentialMetatypeType (
1447
1447
BuiltType instance,
1448
1448
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = None) const {
1449
- BuiltType result = swift_getExistentialMetatypeMetadata (instance);
1450
- if (!result ) {
1449
+ if (instance-> getKind () != MetadataKind::Existential
1450
+ && instance-> getKind () != MetadataKind::ExistentialMetatype ) {
1451
1451
return TYPE_LOOKUP_ERROR_FMT (" Tried to build an existential metatype from "
1452
1452
" a type that was neither an existential nor "
1453
1453
" an existential metatype" );
1454
1454
}
1455
- return result ;
1455
+ return swift_getExistentialMetatypeMetadata (instance) ;
1456
1456
}
1457
1457
1458
1458
TypeLookupErrorOr<BuiltType>
You can’t perform that action at this time.
0 commit comments