Skip to content

Commit 9606f52

Browse files
committed
[IRGen] fix createCXXCopyConstructorFunctionType
The previous implementation assumes `UnsafePointer` has no requirements on its generic parameter. This fix handles any requirements that may be present on the parameter. With NoncopyableGenerics, the generic parameter actually does gain a requirement.
1 parent d727011 commit 9606f52

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/IRGen/GenStruct.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,18 @@ namespace {
589589
// void (%struct.T* %this, %struct.T* %0)
590590
auto ptrTypeDecl =
591591
IGF.getSILModule().getASTContext().getUnsafePointerDecl();
592-
auto subst = SubstitutionMap::get(ptrTypeDecl->getGenericSignature(),
593-
{T.getASTType()},
594-
ArrayRef<ProtocolConformanceRef>{});
592+
auto sig = ptrTypeDecl->getGenericSignature();
593+
594+
// Map the generic parameter to T
595+
auto params = sig.getGenericParams();
596+
assert(params.size() == 1);
597+
auto param = params[0]->getCanonicalType()->castTo<SubstitutableType>();
598+
TypeSubstitutionMap map;
599+
map[param] = T.getASTType();
600+
601+
auto subst = SubstitutionMap::get(sig,
602+
QueryTypeSubstitutionMap{map},
603+
LookUpConformanceInModule{IGF.getSwiftModule()});
595604
auto ptrType = ptrTypeDecl->getDeclaredInterfaceType().subst(subst);
596605
SILParameterInfo ptrParam(ptrType->getCanonicalType(),
597606
ParameterConvention::Direct_Unowned);

0 commit comments

Comments
 (0)