Skip to content

Commit 21537af

Browse files
committed
[IRGen] Prevent descriptor emission.
1 parent f4bab4c commit 21537af

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/IRGen/GenKeyPath.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ emitKeyPathComponent(IRGenModule &IGM,
753753
llvm_unreachable("not struct or class");
754754
}
755755
case KeyPathPatternComponent::Kind::GettableProperty:
756-
case KeyPathPatternComponent::Kind::SettableProperty: {
756+
case KeyPathPatternComponent::Kind::SettableProperty:
757+
case KeyPathPatternComponent::Kind::Method: {
757758
// If the component references an external property, encode that in a
758759
// header before the local attempt header, so that we can consult the
759760
// external descriptor at instantiation time.
@@ -808,11 +809,13 @@ emitKeyPathComponent(IRGenModule &IGM,
808809
});
809810
}
810811
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+
}
816819
for (auto *arg : externalSubArgs)
817820
fields.addRelativeAddress(arg);
818821
}
@@ -1165,6 +1168,7 @@ IRGenModule::getAddrOfKeyPathPattern(KeyPathPattern *pattern,
11651168
switch (component.getKind()) {
11661169
case KeyPathPatternComponent::Kind::GettableProperty:
11671170
case KeyPathPatternComponent::Kind::SettableProperty:
1171+
case KeyPathPatternComponent::Kind::Method:
11681172
for (auto &index : component.getArguments()) {
11691173
operands[index.Operand].LoweredType = index.LoweredType;
11701174
operands[index.Operand].LastUser = &component;

0 commit comments

Comments
 (0)