@@ -264,41 +264,6 @@ MetadataDependency MetadataDependencyCollector::finish(IRGenFunction &IGF) {
264264 return result;
265265}
266266
267- static bool usesExtendedExistentialMetadata (CanType type) {
268- auto layout = type.getExistentialLayout ();
269- // If there are parameterized protocol types that we want to
270- // treat as equal to unparameterized protocol types (maybe
271- // something like `P<some Any>`?), then AST type canonicalization
272- // should turn them into unparameterized protocol types. If the
273- // structure makes it to IRGen, we have to honor that decision that
274- // they represent different types.
275- return !layout.getParameterizedProtocols ().empty ();
276- }
277-
278- static std::optional<std::pair<CanExistentialType, /* depth*/ unsigned >>
279- usesExtendedExistentialMetadata (CanExistentialMetatypeType type) {
280- unsigned depth = 1 ;
281- auto cur = type.getInstanceType ();
282- while (auto metatype = dyn_cast<ExistentialMetatypeType>(cur)) {
283- cur = metatype.getInstanceType ();
284- depth++;
285- }
286-
287- // The only existential types that don't currently use ExistentialType
288- // are Any and AnyObject, which don't use extended metadata.
289- if (usesExtendedExistentialMetadata (cur)) {
290- // HACK: The AST for an existential metatype of a (parameterized) protocol
291- // still directly wraps the existential type as its instance, which means
292- // we need to reconstitute the enclosing ExistentialType.
293- assert (cur->isExistentialType ());
294- if (!cur->is <ExistentialType>()) {
295- cur = ExistentialType::get (cur)->getCanonicalType ();
296- }
297- return std::make_pair (cast<ExistentialType>(cur), depth);
298- }
299- return std::nullopt ;
300- }
301-
302267llvm::Constant *IRGenModule::getAddrOfStringForMetadataRef (
303268 StringRef symbolName,
304269 unsigned alignment,
@@ -1998,7 +1963,7 @@ namespace {
19981963
19991964 // Existential metatypes for extended existentials don't use
20001965 // ExistentialMetatypeMetadata.
2001- if (usesExtendedExistentialMetadata ( type)) {
1966+ if (type-> getExistentialLayout (). needsExtendedShape ( )) {
20021967 auto metadata = emitExtendedExistentialTypeMetadata (type);
20031968 return setLocal (type, MetadataResponse::forComplete (metadata));
20041969 }
@@ -3110,8 +3075,8 @@ static bool shouldAccessByMangledName(IRGenModule &IGM, CanType type) {
31103075 void visitExistentialMetatypeType (CanExistentialMetatypeType meta) {
31113076 // Extended existential metatypes just emit a different shape
31123077 // and don't do any wrapping.
3113- if (auto typeAndDepth = usesExtendedExistentialMetadata ( meta)) {
3114- return visit (typeAndDepth. first );
3078+ if (meta-> getExistentialLayout (). needsExtendedShape ( )) {
3079+ // return visit(unwrapExistentialMetatype(meta) );
31153080 }
31163081
31173082 // The number of accesses turns out the same as the instance type,
0 commit comments