Skip to content

Commit ce64106

Browse files
committed
[TypeChecker] Distributed: Verify properties before attempting to synthesize a thunk
1 parent 567924f commit ce64106

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,9 @@ FuncDecl *GetDistributedThunkRequest::evaluate(Evaluator &evaluator,
826826
if (!var->isDistributed())
827827
return nullptr;
828828

829+
if (checkDistributedActorProperty(var, /*diagnose=*/false))
830+
return nullptr;
831+
829832
distributedTarget = var->getAccessor(AccessorKind::Get);
830833
} else {
831834
distributedTarget = originator.get<AbstractFunctionDecl *>();
@@ -850,7 +853,8 @@ FuncDecl *GetDistributedThunkRequest::evaluate(Evaluator &evaluator,
850853
// we must avoid synthesis of the thunk because it'd also have errors,
851854
// giving an ugly user experience (errors in implicit code).
852855
if (distributedTarget->getInterfaceType()->hasError() ||
853-
checkDistributedFunction(distributedTarget)) {
856+
(!isa<AccessorDecl>(distributedTarget) &&
857+
checkDistributedFunction(distributedTarget))) {
854858
return nullptr;
855859
}
856860

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "swift/AST/TypeCheckRequests.h"
2727
#include "swift/AST/TypeVisitor.h"
2828
#include "swift/AST/ExistentialLayout.h"
29+
#include "swift/Basic/Defer.h"
2930

3031
using namespace swift;
3132

@@ -577,6 +578,13 @@ bool swift::checkDistributedActorProperty(VarDecl *var, bool diagnose) {
577578
auto &C = var->getASTContext();
578579
auto DC = var->getDeclContext();
579580

581+
DiagnosticTransaction transaction(C.Diags);
582+
583+
SWIFT_DEFER {
584+
if (!diagnose)
585+
transaction.abort();
586+
};
587+
580588
// without the distributed module, we can't check any of these.
581589
if (!ensureDistributedModuleLoaded(var))
582590
return true;

0 commit comments

Comments
 (0)