Skip to content

Commit 9d56ead

Browse files
committed
conformances getting there (#5)
1 parent 3676a95 commit 9d56ead

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

Diff for: lib/Sema/DerivedConformances.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ DerivedConformance::declareDerivedConstantProperty(Identifier name,
494494
VarDecl(/*IsStatic*/ isStatic, VarDecl::Introducer::Let,
495495
SourceLoc(), name, parentDC);
496496
propDecl->setImplicit();
497+
propDecl->setSynthesized();
497498
propDecl->copyFormalAccessFrom(Nominal, /*sourceIsParentContext*/ true);
498499
propDecl->setInterfaceType(propertyInterfaceType);
499500

Diff for: lib/Sema/TypeCheckProtocol.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -2708,8 +2708,30 @@ bool ConformanceChecker::checkActorIsolation(
27082708
Type witnessGlobalActor;
27092709
switch (auto witnessRestriction =
27102710
ActorIsolationRestriction::forDeclaration(witness)) {
2711-
case ActorIsolationRestriction::ActorSelf:
27122711
case ActorIsolationRestriction::DistributedActor: {
2712+
if (witness->isSynthesized()) {
2713+
// Some of our synthesized properties get special treatment,
2714+
// they are always available, regardless if the actor is remote even.
2715+
auto &C = requirement->getASTContext();
2716+
2717+
// actorAddress is special, it is *always* available.
2718+
// even if the actor is 'remote' it is always available and immutable.
2719+
if (witness->getName() == C.Id_actorAddress &&
2720+
witness->getInterfaceType()->isEqual(
2721+
C.getActorAddressDecl()->getDeclaredInterfaceType()))
2722+
return false;
2723+
2724+
// TODO: we don't *really* need to expose the transport like that... reconsider?
2725+
if (witness->getName() == C.Id_actorTransport &&
2726+
witness->getInterfaceType()->isEqual(
2727+
C.getActorTransportDecl()->getDeclaredInterfaceType()))
2728+
return false;
2729+
}
2730+
2731+
// continue checking ActorSelf rules
2732+
LLVM_FALLTHROUGH;
2733+
}
2734+
case ActorIsolationRestriction::ActorSelf: {
27132735
// Actor-isolated witnesses cannot conform to protocol requirements.
27142736
witness->diagnose(diag::actor_isolated_witness,
27152737
witness->getDescriptiveKind(),

Diff for: test/Concurrency/Runtime/distributed_actor_run.swift

-24
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,6 @@
66
import Dispatch
77
import _Concurrency
88

9-
protocol DA {
10-
@actorIndependent
11-
var actorTransport: ActorTransport { get }
12-
}
13-
14-
actor class XXX: DA {
15-
let actorTransport: ActorTransport
16-
// @actorIndependent(unsafe) var actorTransport: ActorTransport {
17-
// self._actorTransport
18-
// }
19-
init(transport: ActorTransport) {
20-
self.actorTransport = transport
21-
}
22-
}
23-
24-
protocol P {
25-
var field: String { get }
26-
}
27-
28-
actor class P1: P {
29-
let field: String = "hello"
30-
}
31-
32-
339
distributed actor class SomeSpecificDistributedActor {
3410
// // @derived let actorTransport: ActorTransport
3511
// // @derived let actorAddress: ActorAddress

0 commit comments

Comments
 (0)