|
29 | 29 | #include "swift/AST/ForeignAsyncConvention.h" |
30 | 30 | #include "swift/AST/ForeignErrorConvention.h" |
31 | 31 | #include "swift/AST/GenericEnvironment.h" |
| 32 | +#include "swift/AST/DistributedDecl.h" |
32 | 33 | #include "swift/AST/GenericSignature.h" |
33 | 34 | #include "swift/AST/Module.h" |
34 | 35 | #include "swift/AST/ModuleLoader.h" |
@@ -627,6 +628,16 @@ class Callee { |
627 | 628 | return fn; |
628 | 629 | } |
629 | 630 | case Kind::WitnessMethod: { |
| 631 | + if (auto func = constant->getFuncDecl()) { |
| 632 | + if (func->isDistributed() && isa<ProtocolDecl>(func->getDeclContext())) { |
| 633 | + // If we're calling cross-actor, we must always use a distributed thunk |
| 634 | + if (!isSameActorIsolated(func, SGF.FunctionDC)) { |
| 635 | + // We must adjust the constant to use a distributed thunk. |
| 636 | + constant = constant->asDistributed(); |
| 637 | + } |
| 638 | + } |
| 639 | + } |
| 640 | + |
630 | 641 | auto constantInfo = |
631 | 642 | SGF.getConstantInfo(SGF.getTypeExpansionContext(), *constant); |
632 | 643 |
|
@@ -700,6 +711,16 @@ class Callee { |
700 | 711 | return createCalleeTypeInfo(SGF, constant, constantInfo.getSILType()); |
701 | 712 | } |
702 | 713 | case Kind::WitnessMethod: { |
| 714 | + if (auto func = constant->getFuncDecl()) { |
| 715 | + if (func->isDistributed() && isa<ProtocolDecl>(func->getDeclContext())) { |
| 716 | + // If we're calling cross-actor, we must always use a distributed thunk |
| 717 | + if (!isSameActorIsolated(func, SGF.FunctionDC)) { |
| 718 | + /// We must adjust the constant to use a distributed thunk. |
| 719 | + constant = constant->asDistributed(); |
| 720 | + } |
| 721 | + } |
| 722 | + } |
| 723 | + |
703 | 724 | auto constantInfo = |
704 | 725 | SGF.getConstantInfo(SGF.getTypeExpansionContext(), *constant); |
705 | 726 | return createCalleeTypeInfo(SGF, constant, constantInfo.getSILType()); |
|
0 commit comments