Skip to content

Commit 3292aaa

Browse files
committed
IRGen: Detect nested generic types during generation of the vwt of specialized metadata
The previous code would not detect Container<T>.NonFixed but only NonFixed<T>. For code size reasons we want to use the generic value witness functions rather than specialized ones in specialized metadata.
1 parent 9b7dafb commit 3292aaa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/IRGen/GenValueWitness.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,16 +1387,16 @@ static void addValueWitnessesForAbstractType(IRGenModule &IGM,
13871387
// reasons to continue using "generic" value witness table functions i.e the
13881388
// same once used for runtime instantiated generic metadata.
13891389
if (!IGM.Context.LangOpts.hasFeature(Feature::EmbeddedExistentials)) {
1390-
if (auto boundGenericType = dyn_cast<BoundGenericType>(abstractType)) {
1390+
auto *nomDecl = abstractType->getNominalOrBoundGenericNominal();
1391+
if (abstractType->isSpecialized() && nomDecl) {
13911392
CanType concreteFormalType = getFormalTypeInPrimaryContext(abstractType);
13921393

13931394
auto concreteLoweredType = IGM.getLoweredType(concreteFormalType);
13941395
const auto *boundConcreteTI = &IGM.getTypeInfo(concreteLoweredType);
13951396
auto packing = boundConcreteTI->getFixedPacking(IGM);
13961397
boundGenericCharacteristics = {concreteLoweredType, boundConcreteTI,
13971398
packing};
1398-
abstractType =
1399-
boundGenericType->getDecl()->getDeclaredType()->getCanonicalType();
1399+
abstractType = nomDecl->getDeclaredType()->getCanonicalType();
14001400
}
14011401
}
14021402
CanType concreteFormalType = getFormalTypeInPrimaryContext(abstractType);

0 commit comments

Comments
 (0)