Skip to content

Commit e004e6a

Browse files
committed
[Distributed] fix access level of synthesized default dist init
1 parent 9f1fedb commit e004e6a

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ static ConstructorDecl *createImplicitConstructor(NominalTypeDecl *decl,
321321
"Only 'distributed actor' type can gain implicit distributed actor init");
322322

323323
if (swift::ensureDistributedModuleLoaded(decl)) {
324+
// copy access level of distributed actor init from the nominal decl
325+
accessLevel = decl->getEffectiveAccess();
326+
324327
auto transportDecl = ctx.getActorTransportDecl();
325328

326329
// Create the parameter.

lib/Sema/DerivedConformanceDistributedActor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ static ValueDecl *deriveDistributedActor_actorTransport(
160160

161161
ValueDecl *DerivedConformance::deriveDistributedActor(ValueDecl *requirement) {
162162
if (auto var = dyn_cast<VarDecl>(requirement)) {
163-
fprintf(stderr, "[%s:%d] (%s) DERIVE: [%s]\n", __FILE__, __LINE__, __FUNCTION__, var->getName().str().str().c_str());
164-
165163
if (var->getName() == Context.Id_id)
166164
return deriveDistributedActor_id(*this);
167165

@@ -170,8 +168,6 @@ ValueDecl *DerivedConformance::deriveDistributedActor(ValueDecl *requirement) {
170168
}
171169

172170
if (auto func = dyn_cast<FuncDecl>(requirement)) {
173-
fprintf(stderr, "[%s:%d] (%s) DERIVE: [%s]\n", __FILE__, __LINE__, __FUNCTION__, func->getName().getBaseIdentifier().str().str().c_str());
174-
175171
// just a simple name check is enough here,
176172
// if we are invoked here we know for sure it is for the "right" function
177173
if (func->getName().getBaseName() == Context.Id_resolve)

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,21 +2930,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
29302930

29312931
TypeChecker::checkDeclAttributes(ED);
29322932

2933-
fprintf(stderr, "[%s:%d] (%s) VISIT EXTENSION\n", __FILE__, __LINE__, __FUNCTION__);
2934-
if (nominal->isDistributedActor()) {
2935-
auto decl = dyn_cast<ClassDecl>(nominal);
2936-
TypeChecker::checkDistributedActor(decl);
2937-
2938-
fprintf(stderr, "[%s:%d] (%s) VISIT DIST ACTOR MEMBERS FROM EXTENSION\n", __FILE__, __LINE__, __FUNCTION__);
2939-
for (Decl *Member : ED->getMembers()) {
2940-
if (auto var = dyn_cast<VarDecl>(Member))
2941-
fprintf(stderr, "[%s:%d] (%s) VISIT MEMBER: [%s]\n", __FILE__, __LINE__, __FUNCTION__, var->getName().str().str().c_str());
2942-
if (auto func = dyn_cast<FuncDecl>(Member))
2943-
fprintf(stderr, "[%s:%d] (%s) VISIT MEMBER: [%s]\n", __FILE__, __LINE__, __FUNCTION__, func->getName().getBaseName().getIdentifier().str().str().c_str());
2944-
}
2945-
2946-
}
2947-
29482933
for (Decl *Member : ED->getMembers())
29492934
visit(Member);
29502935

@@ -2955,6 +2940,11 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
29552940
checkAccessControl(ED);
29562941

29572942
checkExplicitAvailability(ED);
2943+
2944+
if (nominal->isDistributedActor()) {
2945+
auto decl = dyn_cast<ClassDecl>(nominal);
2946+
TypeChecker::checkDistributedActor(decl);
2947+
}
29582948
}
29592949

29602950
void visitTopLevelCodeDecl(TopLevelCodeDecl *TLCD) {

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ void swift::checkDistributedActorConstructor(const ClassDecl *decl, ConstructorD
215215
// ==== ------------------------------------------------------------------------
216216

217217
void TypeChecker::checkDistributedActor(ClassDecl *decl) {
218-
fprintf(stderr, "[%s:%d] (%s) CHECK DIST [%s]\n", __FILE__, __LINE__, __FUNCTION__, decl->getNameStr().str().c_str());
219218
if (!decl)
220219
return;
221220

test/Serialization/distributed.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import _Distributed
1414
import def_distributed
1515

1616
func testDoSomethingDistributed(transport: ActorTransport) {
17-
let da = DA(transport: transport)
17+
let _: DA = DA(transport: transport)
1818
}
1919

2020
extension DA {

0 commit comments

Comments
 (0)