Skip to content

Commit b4e8bbb

Browse files
committed
[Distributed] Remove deinit AST synthesis, now handled in SILGenDestructor
1 parent 3c76419 commit b4e8bbb

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -92,76 +92,6 @@ static void addFactoryResolveFunction(ClassDecl *decl) {
9292
decl->addMember(factoryDecl);
9393
}
9494

95-
/******************************************************************************/
96-
/******************************** DEINIT **************************************/
97-
/******************************************************************************/
98-
99-
/// A distributed actor's deinit MUST call `transport.resignIdentity` before it
100-
/// is deallocated.
101-
static void addImplicitResignIdentity(ClassDecl *decl) {
102-
auto &C = decl->getASTContext();
103-
104-
DestructorDecl *existingDeinit = decl->getDestructor();
105-
assert(existingDeinit);
106-
107-
DestructorDecl *deinitDecl = existingDeinit ? existingDeinit :
108-
new (C) DestructorDecl(SourceLoc(), decl);
109-
// DestructorDecl *deinitDecl = new (C) DestructorDecl(SourceLoc(), decl);
110-
111-
BraceStmt *body = deinitDecl->getBody();
112-
113-
// == Copy all existing statements to the new deinit
114-
SmallVector<ASTNode, 2> statements; // TODO: how to init at body statements count size?
115-
for (auto stmt : body->getElements())
116-
statements.push_back(stmt); // TODO: copy?
117-
118-
// TODO: INJECT THIS AS FIRST THING IN A DEFER {}
119-
120-
// == Inject the lifecycle 'resignIdentity' interaction
121-
// ==== self
122-
auto *selfRef = DerivedConformance::createSelfDeclRef(deinitDecl);
123-
124-
// ==== `self.actorTransport`
125-
auto *varTransportExpr = UnresolvedDotExpr::createImplicit(C, selfRef,
126-
C.Id_actorTransport);
127-
128-
// ==== `self.id`
129-
auto *varIdExpr = UnresolvedDotExpr::createImplicit(C, selfRef, C.Id_id);
130-
131-
// ==== `self.transport.resignIdentity(self.actorAddress)`
132-
// auto resignIdentityRef = new (C) DeclRefExpr(varTransportExpr,
133-
// DeclNameLoc(), /*implicit=*/true);
134-
// resignIdentityRef->setThrows(false);
135-
auto resignFuncDecls =
136-
C.getActorTransportDecl()->lookupDirect(C.Id_resignIdentity);
137-
assert(resignFuncDecls.size() == 1);
138-
AbstractFunctionDecl *resignFuncDecl =
139-
dyn_cast<AbstractFunctionDecl>(resignFuncDecls.front());
140-
auto resignFuncRef = new (C) DeclRefExpr(resignFuncDecl, DeclNameLoc(),
141-
/*implicit=*/true);
142-
143-
auto *idParam = new (C) ParamDecl(
144-
SourceLoc(), SourceLoc(), Identifier(),
145-
SourceLoc(), C.Id_id, decl);
146-
idParam->setInterfaceType(C.getActorIdentityDecl()->getInterfaceType());
147-
idParam->setSpecifier(ParamSpecifier::Default);
148-
idParam->setImplicit();
149-
auto *paramList = ParameterList::createWithoutLoc(idParam);
150-
151-
auto *resignFuncRefRef = UnresolvedDotExpr::createImplicit(
152-
C, varTransportExpr, C.Id_resignIdentity, paramList);
153-
154-
Expr *resignIdentityCall = CallExpr::createImplicit(C, resignFuncRefRef,
155-
{ varIdExpr },
156-
{ Identifier() });
157-
statements.push_back(resignIdentityCall);
158-
159-
BraceStmt *newBody = BraceStmt::create(C, SourceLoc(), statements, SourceLoc(),
160-
/*implicit=*/true);
161-
162-
deinitDecl->setBody(newBody, AbstractFunctionDecl::BodyKind::TypeChecked); // FIXME: no idea if Parsed is right, we are NOT type checked I guess?
163-
}
164-
16595
/******************************************************************************/
16696
/******************************** PROPERTIES **********************************/
16797
/******************************************************************************/
@@ -425,5 +355,4 @@ void swift::addImplicitDistributedActorMembersToClass(ClassDecl *decl) {
425355
addFactoryResolveFunction(decl);
426356
addImplicitDistributedActorStoredProperties(decl);
427357
addImplicitRemoteActorFunctions(decl);
428-
// addImplicitResignIdentity(decl);
429358
}

0 commit comments

Comments
 (0)