@@ -649,9 +649,10 @@ getInitializerForComputedComponent(IRGenModule &IGM,
649
649
}
650
650
651
651
static llvm::Constant *
652
- emitMetadataTypeRefForKeyPath (IRGenModule &IGM, CanType type) {
652
+ emitMetadataTypeRefForKeyPath (IRGenModule &IGM, CanType type,
653
+ CanGenericSignature sig) {
653
654
// Produce a mangled name for the type.
654
- auto constant = IGM.getTypeRef (type, MangledTypeRefRole::Metadata).first ;
655
+ auto constant = IGM.getTypeRef (type, sig, MangledTypeRefRole::Metadata).first ;
655
656
656
657
// Mask the bottom bit to tell the key path runtime this is a mangled name
657
658
// rather than a direct reference.
@@ -837,6 +838,10 @@ emitKeyPathComponent(IRGenModule &IGM,
837
838
SmallVector<llvm::Constant *, 4 > externalSubArgs;
838
839
auto componentSig = externalDecl->getInnermostDeclContext ()
839
840
->getGenericSignatureOfContext ();
841
+
842
+ auto componentCanSig = componentSig
843
+ ? componentSig->getCanonicalSignature ()
844
+ : CanGenericSignature ();
840
845
auto subs = component.getExternalSubstitutions ();
841
846
if (!subs.empty ()) {
842
847
enumerateGenericSignatureRequirements (
@@ -847,7 +852,7 @@ emitKeyPathComponent(IRGenModule &IGM,
847
852
if (!reqt.Protocol ) {
848
853
// Type requirement.
849
854
externalSubArgs.push_back (
850
- emitMetadataTypeRefForKeyPath (IGM, substType));
855
+ emitMetadataTypeRefForKeyPath (IGM, substType, componentCanSig ));
851
856
} else {
852
857
// Protocol requirement.
853
858
auto conformance = subs.lookupConformance (
@@ -1182,9 +1187,11 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
1182
1187
getAddrOfGenericEnvironment (pattern->getGenericSignature ()));
1183
1188
// Store type references for the root and leaf.
1184
1189
fields.addRelativeAddress (
1185
- emitMetadataTypeRefForKeyPath (*this , rootTy));
1190
+ emitMetadataTypeRefForKeyPath (*this , rootTy,
1191
+ pattern->getGenericSignature ()));
1186
1192
fields.addRelativeAddress (
1187
- emitMetadataTypeRefForKeyPath (*this , valueTy));
1193
+ emitMetadataTypeRefForKeyPath (*this , valueTy,
1194
+ pattern->getGenericSignature ()));
1188
1195
1189
1196
// Add a pointer to the ObjC KVC compatibility string, if there is one, or
1190
1197
// null otherwise.
@@ -1238,7 +1245,9 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
1238
1245
// For all but the last component, we pack in the type of the component.
1239
1246
if (i + 1 != pattern->getComponents ().size ()) {
1240
1247
fields.addRelativeAddress (
1241
- emitMetadataTypeRefForKeyPath (*this , component.getComponentType ()));
1248
+ emitMetadataTypeRefForKeyPath (*this ,
1249
+ component.getComponentType (),
1250
+ pattern->getGenericSignature ()));
1242
1251
}
1243
1252
baseTy = component.getComponentType ();
1244
1253
}
0 commit comments