@@ -189,11 +189,23 @@ namespace {
189189 }
190190 }
191191
192- void collect (IRGenFunction &IGF, CanBoundGenericType type) {
193- GenericTypeRequirements requirements (IGF.IGM , type->getDecl ());
192+ void collect (IRGenFunction &IGF, CanType type) {
193+ NominalTypeDecl *decl;
194+ CanType parentType;
195+
196+ if (auto nominalType = dyn_cast<NominalType>(type)) {
197+ decl = nominalType->getDecl ();
198+ parentType = nominalType.getParent ();
199+ } else {
200+ auto boundType = cast<BoundGenericType>(type);
201+ decl = boundType->getDecl ();
202+ parentType = boundType.getParent ();
203+ }
204+
205+ GenericTypeRequirements requirements (IGF.IGM , decl);
194206
195207 if (requirements.hasParentType ()) {
196- Values.push_back (IGF.emitTypeMetadataRef (type. getParent () ));
208+ Values.push_back (IGF.emitTypeMetadataRef (parentType ));
197209 }
198210
199211 auto subs =
@@ -208,7 +220,7 @@ namespace {
208220 }
209221 });
210222
211- collectTypes (IGF.IGM , type-> getDecl () );
223+ collectTypes (IGF.IGM , decl );
212224 assert (Types.size () == Values.size ());
213225 }
214226 };
@@ -372,8 +384,8 @@ static llvm::Value *emitNominalMetadataRef(IRGenFunction &IGF,
372384 }
373385
374386 // We are applying generic parameters to a generic type.
375- auto boundGeneric = cast<BoundGenericType> (theType);
376- assert (boundGeneric-> getDecl () == theDecl);
387+ assert (theType-> isSpecialized () &&
388+ theType-> getAnyNominal () == theDecl);
377389
378390 // Check to see if we've maybe got a local reference already.
379391 if (auto cache = IGF.tryGetLocalTypeData (theType,
@@ -382,7 +394,7 @@ static llvm::Value *emitNominalMetadataRef(IRGenFunction &IGF,
382394
383395 // Grab the substitutions.
384396 GenericArguments genericArgs;
385- genericArgs.collect (IGF, boundGeneric );
397+ genericArgs.collect (IGF, theType );
386398 assert (genericArgs.Values .size () > 0 && " no generic args?!" );
387399
388400 // Call the generic metadata accessor function.
@@ -451,8 +463,6 @@ bool irgen::isTypeMetadataAccessTrivial(IRGenModule &IGM, CanType type) {
451463 // access if it contains a resilient type.
452464 if (isa<StructType>(type) || isa<EnumType>(type)) {
453465 auto nominalType = cast<NominalType>(type);
454- assert (!nominalType->getDecl ()->isGenericContext () &&
455- " shouldn't be called for a generic type" );
456466
457467 // Imported type metadata always requires an accessor.
458468 if (nominalType->getDecl ()->hasClangNode ())
@@ -529,9 +539,9 @@ irgen::getTypeMetadataAccessStrategy(IRGenModule &IGM, CanType type) {
529539 // Metadata accessors for fully-substituted generic types are
530540 // emitted with shared linkage.
531541 if (nominal->isGenericContext () && !nominal->isObjC ()) {
532- if (isa<BoundGenericType>(type ))
542+ if (type-> isSpecialized ( ))
533543 return MetadataAccessStrategy::NonUniqueAccessor;
534- assert (isa<UnboundGenericType>(type ));
544+ assert (type-> hasUnboundGenericType ( ));
535545 }
536546
537547 // If the type doesn't guarantee that it has an access function,
0 commit comments