Skip to content

Commit 9c63a56

Browse files
authored
Merge pull request #85309 from hamishknight/follow-up
[Sema] A couple of minor follow-ups to #85245
2 parents d1529b5 + 80f426e commit 9c63a56

File tree

10 files changed

+27
-21
lines changed

10 files changed

+27
-21
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ bool conflicting(ASTContext &ctx,
376376

377377
/// The kind of special compiler synthesized property in a \c distributed actor,
378378
/// currently this includes \c id and \c actorSystem.
379-
enum class SpecialDistributedProperty {
379+
enum class SpecialDistributedActorProperty {
380380
Id, ActorSystem
381381
};
382382

@@ -3065,8 +3065,8 @@ class ValueDecl : public Decl {
30653065
/// Whether this is the special synthesized 'id' or 'actorSystem' property
30663066
/// of a distributed actor. If \p onlyCheckName is set, then any
30673067
/// matching user-defined property with the name is also considered.
3068-
std::optional<SpecialDistributedProperty>
3069-
isSpecialDistributedProperty(bool onlyCheckName = false) const;
3068+
std::optional<SpecialDistributedActorProperty>
3069+
isSpecialDistributedActorProperty(bool onlyCheckName = false) const;
30703070

30713071
bool hasName() const { return bool(Name); }
30723072
bool isOperator() const { return Name.isOperator(); }

lib/AST/DistributedDecl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,20 +1358,20 @@ bool ValueDecl::isDistributedGetAccessor() const {
13581358
return false;
13591359
}
13601360

1361-
std::optional<SpecialDistributedProperty>
1362-
ValueDecl::isSpecialDistributedProperty(bool onlyCheckName) const {
1361+
std::optional<SpecialDistributedActorProperty>
1362+
ValueDecl::isSpecialDistributedActorProperty(bool onlyCheckName) const {
13631363
if (!isa<VarDecl>(this))
13641364
return std::nullopt;
13651365

13661366
auto *DC = getDeclContext();
13671367
auto &ctx = DC->getASTContext();
13681368

1369-
auto kind = [&]() -> std::optional<SpecialDistributedProperty> {
1369+
auto kind = [&]() -> std::optional<SpecialDistributedActorProperty> {
13701370
auto name = getName();
13711371
if (name.isSimpleName(ctx.Id_id))
1372-
return SpecialDistributedProperty::Id;
1372+
return SpecialDistributedActorProperty::Id;
13731373
if (name.isSimpleName(ctx.Id_actorSystem))
1374-
return SpecialDistributedProperty::ActorSystem;
1374+
return SpecialDistributedActorProperty::ActorSystem;
13751375

13761376
return std::nullopt;
13771377
}();

lib/SILGen/SILGenDestructor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ void SILGenFunction::emitDistributedRemoteActorDeinit(
5858

5959
auto cleanupLoc = CleanupLocation(loc);
6060

61-
auto &C = cd->getASTContext();
62-
6361
{
6462
FullExpr CleanupScope(Cleanups, cleanupLoc);
6563
ManagedValue borrowedSelf = emitManagedBeginBorrow(loc, selfValue);
@@ -74,7 +72,7 @@ void SILGenFunction::emitDistributedRemoteActorDeinit(
7472
continue;
7573

7674
// Just to double-check, we only want to destroy `id` and `actorSystem`
77-
if (vd->isSpecialDistributedProperty())
75+
if (vd->isSpecialDistributedActorProperty())
7876
destroyClassMember(cleanupLoc, borrowedSelf, vd);
7977
}
8078

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ AssociatedTypeInference::getPotentialTypeWitnessesFromRequirement(
16611661
// witnesses already being resolved.
16621662
if (auto *nominal = dc->getSelfNominalTypeDecl()) {
16631663
if (nominal->isDistributedActor() &&
1664-
req->isSpecialDistributedProperty(/*onlyCheckName*/ true)) {
1664+
req->isSpecialDistributedActorProperty(/*onlyCheckName*/ true)) {
16651665
LLVM_DEBUG(llvm::dbgs() << "skipping special distributed property\n");
16661666
return {};
16671667
}

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@ GetDistributedActorIDPropertyRequest::evaluate(Evaluator &evaluator,
842842
propDecl->setSynthesized();
843843
propDecl->copyFormalAccessFrom(nominal, /*sourceIsParentContext*/ true);
844844

845+
// NOTE: The type for this property is lazily computed by
846+
// `getLazilySynthesizedPattern` when type-checking, which ensures this
847+
// request does not trigger any semantic requests since it's called by name
848+
// lookup.
845849
Pattern *propPat = NamedPattern::createImplicit(C, propDecl);
846850

847851
PatternBindingDecl *pbDecl = PatternBindingDecl::createImplicit(
@@ -891,6 +895,10 @@ VarDecl *GetDistributedActorSystemPropertyRequest::evaluate(
891895
propDecl->setSynthesized();
892896
propDecl->copyFormalAccessFrom(nominal, /*sourceIsParentContext*/ true);
893897

898+
// NOTE: The type for this property is lazily computed by
899+
// `getLazilySynthesizedPattern` when type-checking, which ensures this
900+
// request does not trigger any semantic requests since it's called by name
901+
// lookup.
894902
Pattern *propPat = NamedPattern::createImplicit(C, propDecl);
895903

896904
PatternBindingDecl *pbDecl = PatternBindingDecl::createImplicit(

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7852,7 +7852,7 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
78527852
// The synthesized "id" and "actorSystem" are the only exceptions,
78537853
// because the implementation mirrors them.
78547854
if (nominal->isDistributedActor() &&
7855-
!var->isSpecialDistributedProperty()) {
7855+
!var->isSpecialDistributedActorProperty()) {
78567856
diagnoseAndRemoveAttr(attr,
78577857
diag::nonisolated_distributed_actor_storage);
78587858
return;

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,7 @@ static ArrayRef<Decl *> evaluateMembersRequest(
29482948
// be in a specific order that is different from ordering by their
29492949
// mangled name, so preserve the order
29502950
// they were added in.
2951-
if (vd->isSynthesized() && !vd->isSpecialDistributedProperty()) {
2951+
if (vd->isSynthesized() && !vd->isSpecialDistributedActorProperty()) {
29522952
synthesizedMembers.add(vd);
29532953
return;
29542954
}

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current,
10651065
});
10661066
}
10671067
auto *conflictDecl = current == declToDiagnose ? other : current;
1068-
if (conflictDecl->isSpecialDistributedProperty()) {
1068+
if (conflictDecl->isSpecialDistributedActorProperty()) {
10691069
declToDiagnose->diagnose(
10701070
diag::distributed_actor_user_defined_special_property,
10711071
other->getName());

lib/Sema/TypeCheckStorage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ MemberwiseInitPropertiesRequest::evaluate(Evaluator &evaluator,
390390
static Type getLazyInterfaceTypeForSynthesizedVar(VarDecl *var) {
391391
// For DistributedActor, the `id` and `actorSystem` properties have their
392392
// types computed lazily.
393-
if (auto distPropKind = var->isSpecialDistributedProperty()) {
393+
if (auto distPropKind = var->isSpecialDistributedActorProperty()) {
394394
auto *NTD = var->getDeclContext()->getSelfNominalTypeDecl();
395395
ASSERT(NTD);
396396
switch (distPropKind.value()) {
397-
case SpecialDistributedProperty::Id:
397+
case SpecialDistributedActorProperty::Id:
398398
return getDistributedActorIDType(NTD);
399-
case SpecialDistributedProperty::ActorSystem:
399+
case SpecialDistributedActorProperty::ActorSystem:
400400
return getDistributedActorSystemType(NTD);
401401
}
402402
llvm_unreachable("Unhandled case in switch!");

test/Distributed/rdar162800185.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// RUN: split-file %s %t
33

44
// Make sure we can resolve the conformance to DistributedActor from a secondary.
5-
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple %t/a.swift %t/b.swift -o %/tmp
6-
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple -primary-file %t/a.swift %t/b.swift -o %/tmp
7-
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple %t/a.swift -primary-file %t/b.swift -o %/tmp
5+
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple %t/a.swift %t/b.swift -o %t/out.o
6+
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple -primary-file %t/a.swift %t/b.swift -o %t/out.o
7+
// RUN: %target-swift-frontend -c -module-name main -target %target-swift-5.7-abi-triple %t/a.swift -primary-file %t/b.swift -o %t/out.o
88

99
// REQUIRES: concurrency
1010
// REQUIRES: distributed

0 commit comments

Comments
 (0)