Skip to content

Commit bfa4c39

Browse files
committed
[IRGen] Restore the old code path for emitting existential type metadata
for plain protocol and protocol composition types. These types should always be wrapped in ExistentialType, but there isn't sufficient validation of this throughout the compiler yet. Change the fatal error when the metadata request sees these plain types to an assert and restore the old type metadata emission path for protocol and protocol composition types to avoid crashing in those cases.
1 parent ff387ae commit bfa4c39

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,16 @@ namespace {
18831883

18841884
MetadataResponse visitProtocolType(CanProtocolType type,
18851885
DynamicMetadataRequest request) {
1886-
llvm_unreachable("constraint type should be wrapped in existential type");
1886+
assert(false && "constraint type should be wrapped in existential type");
1887+
1888+
CanExistentialType existential(
1889+
ExistentialType::get(type)->castTo<ExistentialType>());
1890+
1891+
if (auto metatype = tryGetLocal(existential, request))
1892+
return metatype;
1893+
1894+
auto metadata = emitExistentialTypeMetadata(existential);
1895+
return setLocal(type, MetadataResponse::forComplete(metadata));
18871896
}
18881897

18891898
MetadataResponse
@@ -1892,7 +1901,16 @@ namespace {
18921901
if (type->isAny() || type->isAnyObject())
18931902
return emitSingletonExistentialTypeMetadata(type);
18941903

1895-
llvm_unreachable("constraint type should be wrapped in existential type");
1904+
assert(false && "constraint type should be wrapped in existential type");
1905+
1906+
CanExistentialType existential(
1907+
ExistentialType::get(type)->castTo<ExistentialType>());
1908+
1909+
if (auto metatype = tryGetLocal(existential, request))
1910+
return metatype;
1911+
1912+
auto metadata = emitExistentialTypeMetadata(existential);
1913+
return setLocal(type, MetadataResponse::forComplete(metadata));
18961914
}
18971915

18981916
MetadataResponse

0 commit comments

Comments
 (0)