Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/IRGen/GenValueWitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,16 +1387,16 @@ static void addValueWitnessesForAbstractType(IRGenModule &IGM,
// reasons to continue using "generic" value witness table functions i.e the
// same once used for runtime instantiated generic metadata.
if (!IGM.Context.LangOpts.hasFeature(Feature::EmbeddedExistentials)) {
if (auto boundGenericType = dyn_cast<BoundGenericType>(abstractType)) {
auto *nomDecl = abstractType->getNominalOrBoundGenericNominal();
if (abstractType->isSpecialized() && nomDecl) {
CanType concreteFormalType = getFormalTypeInPrimaryContext(abstractType);

auto concreteLoweredType = IGM.getLoweredType(concreteFormalType);
const auto *boundConcreteTI = &IGM.getTypeInfo(concreteLoweredType);
auto packing = boundConcreteTI->getFixedPacking(IGM);
boundGenericCharacteristics = {concreteLoweredType, boundConcreteTI,
packing};
abstractType =
boundGenericType->getDecl()->getDeclaredType()->getCanonicalType();
abstractType = nomDecl->getDeclaredType()->getCanonicalType();
}
}
CanType concreteFormalType = getFormalTypeInPrimaryContext(abstractType);
Expand Down
39 changes: 39 additions & 0 deletions test/IRGen/prespecialized-metadata/nestedtype.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// RUN: %swift -prespecialize-generic-metadata -target %module-target-future -emit-ir %s | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment

// REQUIRES: VENDOR=apple || OS=linux-gnu
// UNSUPPORTED: CPU=i386 && OS=ios
// UNSUPPORTED: CPU=armv7 && OS=ios
// UNSUPPORTED: CPU=armv7s && OS=ios

@inline(never)
func consume<T>(_ t: T) {
withExtendedLifetime(t) { t in
}
}

struct Container<T> {
struct NonFixed {

init( _ t: T) {
w = t
}

var w: T? = nil
var x = 1
var y = 1
var z = 1
}
}


func doit2() {
consume(Container.NonFixed(5))
}

doit2()

// Make sure we use the generic witness table functions rather than specialized
// ones. We do this for code size.

// CHECK: @"$s10nestedtype9ContainerV8NonFixedVySi_GWV" =
// CHECK-SAME: s10nestedtype9ContainerV8NonFixedVwtk