@@ -753,7 +753,8 @@ emitKeyPathComponent(IRGenModule &IGM,
753
753
llvm_unreachable (" not struct or class" );
754
754
}
755
755
case KeyPathPatternComponent::Kind::GettableProperty:
756
- case KeyPathPatternComponent::Kind::SettableProperty: {
756
+ case KeyPathPatternComponent::Kind::SettableProperty:
757
+ case KeyPathPatternComponent::Kind::Method: {
757
758
// If the component references an external property, encode that in a
758
759
// header before the local attempt header, so that we can consult the
759
760
// external descriptor at instantiation time.
@@ -808,11 +809,13 @@ emitKeyPathComponent(IRGenModule &IGM,
808
809
});
809
810
}
810
811
fields.addInt32 (
811
- KeyPathComponentHeader::forExternalComponent (externalSubArgs.size ())
812
- .getData ());
813
- auto descriptor = IGM.getAddrOfLLVMVariableOrGOTEquivalent (
814
- LinkEntity::forPropertyDescriptor (externalDecl));
815
- fields.addRelativeAddress (descriptor);
812
+ KeyPathComponentHeader::forExternalComponent (externalSubArgs.size ())
813
+ .getData ());
814
+ if (auto *decl = dyn_cast<AbstractStorageDecl>(externalDecl)) {
815
+ auto descriptor = IGM.getAddrOfLLVMVariableOrGOTEquivalent (
816
+ LinkEntity::forPropertyDescriptor (decl));
817
+ fields.addRelativeAddress (descriptor);
818
+ }
816
819
for (auto *arg : externalSubArgs)
817
820
fields.addRelativeAddress (arg);
818
821
}
@@ -1165,6 +1168,7 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
1165
1168
switch (component.getKind ()) {
1166
1169
case KeyPathPatternComponent::Kind::GettableProperty:
1167
1170
case KeyPathPatternComponent::Kind::SettableProperty:
1171
+ case KeyPathPatternComponent::Kind::Method:
1168
1172
for (auto &index : component.getArguments ()) {
1169
1173
operands[index.Operand ].LoweredType = index.LoweredType ;
1170
1174
operands[index.Operand ].LastUser = &component;
0 commit comments