Skip to content

Commit 9289d08

Browse files
authored
Merge pull request #38914 from ktoso/wip-enable-runtime-tests-again
[Distributed] Re-enable runtime tests
2 parents f458d9b + d5a2344 commit 9289d08

16 files changed

+42
-64
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,10 +4459,10 @@ NOTE(actor_isolated_sync_func,none,
44594459
"implicitly asynchronous",
44604460
(DescriptiveDeclKind, DeclName))
44614461
NOTE(distributed_actor_isolated_method_note,none,
4462-
"only 'distributed' functions can be called from outside the distributed actor", // TODO: improve error message
4462+
"only 'distributed' functions can be called from outside the distributed actor", // TODO(distributed): improve error message
44634463
())
44644464
ERROR(distributed_actor_isolated_method,none,
4465-
"only 'distributed' functions can be called from outside the distributed actor", // TODO: improve error message to be more like 'non-distributed' ... defined here
4465+
"only 'distributed' functions can be called from outside the distributed actor", // TODO(distributed): improve error message to be more like 'non-distributed' ... defined here
44664466
())
44674467
ERROR(distributed_actor_func_param_not_codable,none,
44684468
"distributed function parameter '%0' of type %1 does not conform to 'Codable'",

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ AbstractFunctionDecl *TypeChecker::addImplicitDistributedActorRemoteFunction(
175175
// nonisolated
176176
remoteFuncDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit=*/true));
177177

178+
// nonisolated
179+
remoteFuncDecl->getAttrs().add(
180+
new (C) NonisolatedAttr(/*IsImplicit=*/true));
181+
178182
// users should never have to access this function directly;
179183
// it is only invoked from our distributed function thunk if the actor is remote.
180184
remoteFuncDecl->setUserAccessible(false);

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ namespace {
13841384
decl->diagnose(diag::distributed_actor_isolated_method_note);
13851385
}
13861386
} else if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
1387-
func->diagnose(diag::actor_isolated_sync_func, // FIXME: this is emitted wrongly for self.hello()
1387+
func->diagnose(diag::actor_isolated_sync_func,
13881388
decl->getDescriptiveKind(),
13891389
decl->getName());
13901390

test/Distributed/Runtime/distributed_actor_deinit.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
import _Distributed
1414

1515
@available(SwiftStdlib 5.5, *)
16-
actor A {}
16+
actor A {}
1717

1818
@available(SwiftStdlib 5.5, *)
1919
distributed actor DA {
2020
init(transport: ActorTransport) {
21-
defer { transport.actorReady(self) }
21+
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
2222
}
2323
}
2424

2525
@available(SwiftStdlib 5.5, *)
2626
distributed actor DA_userDefined {
2727
init(transport: ActorTransport) {
28-
defer { transport.actorReady(self) }
28+
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
2929
}
3030

3131
deinit {}
@@ -34,7 +34,7 @@ distributed actor DA_userDefined {
3434
@available(SwiftStdlib 5.5, *)
3535
distributed actor DA_userDefined2 {
3636
init(transport: ActorTransport) {
37-
defer { transport.actorReady(self) }
37+
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
3838
}
3939

4040
deinit {
@@ -49,7 +49,7 @@ distributed actor DA_state {
4949
var age = 42
5050

5151
init(transport: ActorTransport) {
52-
defer { transport.actorReady(self) }
52+
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
5353
}
5454

5555
deinit {

test/Distributed/Runtime/distributed_actor_dynamic_remote_func.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
// UNSUPPORTED: use_os_stdlib
88
// UNSUPPORTED: back_deployment_runtime
99

10-
// REQUIRES: rdar78290608
10+
// FIXME(distributed): remote functions dont seem to work on windows?
11+
// XFAIL: OS=windows-msvc
1112

1213
import _Distributed
1314

1415
@available(SwiftStdlib 5.5, *)
1516
distributed actor LocalWorker {
17+
init(transport: ActorTransport) {
18+
defer { transport.actorReady(self) } // FIXME(distributed): rdar://81783599 this should be injected automatically
19+
}
20+
1621
distributed func function() async throws -> String {
1722
"local:"
1823
}
@@ -25,13 +30,13 @@ distributed actor LocalWorker {
2530
@available(SwiftStdlib 5.5, *)
2631
extension LocalWorker {
2732
@_dynamicReplacement(for: _remote_function())
28-
// TODO: @_remoteDynamicReplacement(for: function()) - could be a nicer spelling, hiding that we use dynamic under the covers
33+
// TODO(distributed): @_remoteDynamicReplacement(for: function()) - could be a nicer spelling, hiding that we use dynamic under the covers
2934
func _cluster_remote_function() async throws -> String {
3035
"\(#function):"
3136
}
3237

3338
@_dynamicReplacement(for: _remote_echo(name:))
34-
// TODO: @_remoteDynamicReplacement(for: hello(name:)) - could be a nicer spelling, hiding that we use dynamic under the covers
39+
// TODO(distributed): @_remoteDynamicReplacement(for: hello(name:)) - could be a nicer spelling, hiding that we use dynamic under the covers
3540
func _cluster_remote_echo(name: String) async throws -> String {
3641
"\(#function):\(name)"
3742
}
@@ -95,7 +100,7 @@ func test_remote() async throws {
95100
let address = ActorAddress(parse: "")
96101
let transport = FakeTransport()
97102

98-
let worker = try LocalWorkerresolve(.init(address), using: transport)
103+
let worker = try LocalWorker.resolve(.init(address), using: transport)
99104
let x = try await worker.function()
100105
print("call: \(x)")
101106
// CHECK: call: _cluster_remote_function():

test/Distributed/Runtime/distributed_actor_init_local.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// UNSUPPORTED: use_os_stdlib
99
// UNSUPPORTED: back_deployment_runtime
1010

11-
// REQUIRES: rdar78290608
12-
1311
import _Distributed
1412

1513
@available(SwiftStdlib 5.5, *)

test/Distributed/Runtime/distributed_actor_isRemote.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// UNSUPPORTED: use_os_stdlib
99
// UNSUPPORTED: back_deployment_runtime
1010

11-
// REQUIRES: rdar78290608
11+
// FIXME(distributed): remote functions dont seem to work on windows?
12+
// XFAIL: OS=windows-msvc
1213

1314
import _Distributed
1415

test/Distributed/Runtime/distributed_actor_local.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
// REQUIRES: concurrency
55
// REQUIRES: distributed
66

7+
// rdar://83859906
8+
// UNSUPPORTED: OS=windows-msvc
9+
10+
711
// rdar://76038845
812
// UNSUPPORTED: use_os_stdlib
913
// UNSUPPORTED: back_deployment_runtime
1014

11-
// REQUIRES: rdar78290608
12-
1315
import _Distributed
1416

1517
@available(SwiftStdlib 5.5, *)

test/Distributed/Runtime/distributed_actor_remote_fieldsDontCrashDeinit.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// UNSUPPORTED: use_os_stdlib
99
// UNSUPPORTED: back_deployment_runtime
1010

11-
1211
import _Distributed
1312

1413
@available(SwiftStdlib 5.5, *)

test/Distributed/Runtime/distributed_actor_remote_functions.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ struct FakeTransport: ActorTransport {
149149
fatalError("not implemented:\(#function)")
150150
}
151151

152-
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type)
153-
throws -> Act?
152+
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type) throws -> Act?
154153
where Act: DistributedActor {
155-
return nil
154+
nil
156155
}
157156

158157
func assignIdentity<Act>(_ actorType: Act.Type) -> AnyActorIdentity

test/Distributed/Runtime/distributed_actor_remote_retains_transport.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -parse-as-library) | %FileCheck %s --dump-input=always
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-distributed -Xfrontend -disable-availability-checking -parse-as-library) | %FileCheck %s --dump-input=always
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
@@ -8,11 +8,8 @@
88
// UNSUPPORTED: use_os_stdlib
99
// UNSUPPORTED: back_deployment_runtime
1010

11-
// REQUIRES: rdar78290608
12-
1311
import _Distributed
1412

15-
@available(SwiftStdlib 5.5, *)
1613
distributed actor SomeSpecificDistributedActor {
1714
deinit {
1815
print("deinit \(self.id)")
@@ -21,25 +18,21 @@ distributed actor SomeSpecificDistributedActor {
2118

2219
// ==== Fake Transport ---------------------------------------------------------
2320

24-
@available(SwiftStdlib 5.5, *)
2521
struct FakeActorID: ActorIdentity {
2622
let id: UInt64
2723
}
2824

29-
@available(SwiftStdlib 5.5, *)
3025
enum FakeTransportError: ActorTransportError {
3126
case unsupportedActorIdentity(AnyActorIdentity)
3227
}
3328

34-
@available(SwiftStdlib 5.5, *)
3529
struct ActorAddress: ActorIdentity {
3630
let address: String
3731
init(parse address : String) {
3832
self.address = address
3933
}
4034
}
4135

42-
@available(SwiftStdlib 5.5, *)
4336
final class FakeTransport: ActorTransport {
4437

4538
deinit {
@@ -74,12 +67,11 @@ final class FakeTransport: ActorTransport {
7467

7568
// ==== Execute ----------------------------------------------------------------
7669

77-
@available(SwiftStdlib 5.5, *)
7870
func test_remote() async {
79-
var address = ActorAddress(parse: "sact://127.0.0.1/example#1234")
71+
let address = ActorAddress(parse: "sact://127.0.0.1/example#1234")
8072
var transport: ActorTransport? = FakeTransport()
8173

82-
var remote = try! SomeSpecificDistributedActor.resolve(.init(address), using: transport!)
74+
let remote = try! SomeSpecificDistributedActor.resolve(.init(address), using: transport!)
8375

8476
transport = nil
8577
print("done") // CHECK: done
@@ -88,12 +80,11 @@ func test_remote() async {
8880
print("remote.transport = \(remote.actorTransport)") // CHECK: remote.transport = main.FakeTransport
8981

9082
// only once we exit the function and the remote is released, the transport has no more references
91-
// CHECK: deinit AnyActorIdentity(ActorAddress(address: "sact://127.0.0.1/example#1234"))
83+
// CHECK-DAG: deinit AnyActorIdentity(ActorAddress(address: "sact://127.0.0.1/example#1234"))
9284
// transport must deinit after the last actor using it does deinit
93-
// CHECK: deinit main.FakeTransport
85+
// CHECK-DAG: deinit main.FakeTransport
9486
}
9587

96-
@available(SwiftStdlib 5.5, *)
9788
@main struct Main {
9889
static func main() async {
9990
await test_remote()

test/Distributed/Runtime/distributed_no_transport_boom.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
// REQUIRES: concurrency
1010
// REQUIRES: distributed
1111

12-
// REQUIRES: rdar78290608
12+
// FIXME(distributed): remote functions dont seem to work on windows?
13+
// XFAIL: OS=windows-msvc
1314

1415
import _Distributed
1516

@@ -36,8 +37,7 @@ struct FakeTransport: ActorTransport {
3637
fatalError("not implemented:\(#function)")
3738
}
3839

39-
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type)
40-
throws -> Act?
40+
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type) throws -> Act?
4141
where Act: DistributedActor {
4242
return nil
4343
}
@@ -68,7 +68,7 @@ func test_remote() async {
6868
let remote = try! SomeSpecificDistributedActor.resolve(.init(address), using: transport)
6969
_ = try! await remote.hello() // let it crash!
7070

71-
// CHECK: SOURCE_DIR/test/Distributed/Runtime/distributed_no_transport_boom.swift:18: Fatal error: Invoked remote placeholder function '_remote_hello' on remote distributed actor of type 'main.SomeSpecificDistributedActor'. Configure an appropriate 'ActorTransport' for this actor to resolve this error (e.g. by depending on some specific transport library).
71+
// CHECK: SOURCE_DIR/test/Distributed/Runtime/distributed_no_transport_boom.swift:{{[0-9]+}}: Fatal error: Invoked remote placeholder function '_remote_hello' on remote distributed actor of type 'main.SomeSpecificDistributedActor'. Configure an appropriate 'ActorTransport' for this actor to resolve this error (e.g. by depending on some specific transport library).
7272
}
7373

7474
@available(SwiftStdlib 5.5, *)

test/Distributed/actor_protocols.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import _Distributed
66

77
// ==== -----------------------------------------------------------------------
88

9-
@available(SwiftStdlib 5.5, *)
109
actor A: Actor {} // ok
1110

12-
@available(SwiftStdlib 5.5, *)
1311
class C: Actor, UnsafeSendable {
1412
// expected-error@-1{{non-actor type 'C' cannot conform to the 'Actor' protocol}} {{1-6=actor}}
1513
// expected-warning@-2{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
@@ -18,15 +16,13 @@ class C: Actor, UnsafeSendable {
1816
}
1917
}
2018

21-
@available(SwiftStdlib 5.5, *)
2219
struct S: Actor {
2320
// expected-error@-1{{non-class type 'S' cannot conform to class protocol 'Actor'}}
2421
nonisolated var unownedExecutor: UnownedSerialExecutor {
2522
fatalError()
2623
}
2724
}
2825

29-
@available(SwiftStdlib 5.5, *)
3026
struct E: Actor {
3127
// expected-error@-1{{non-class type 'E' cannot conform to class protocol 'Actor'}}
3228
nonisolated var unownedExecutor: UnownedSerialExecutor {
@@ -36,10 +32,8 @@ struct E: Actor {
3632

3733
// ==== -----------------------------------------------------------------------
3834

39-
@available(SwiftStdlib 5.5, *)
4035
distributed actor DA: DistributedActor {} // ok
4136

42-
@available(SwiftStdlib 5.5, *)
4337
actor A2: DistributedActor {
4438
// expected-error@-1{{non-distributed actor type 'A2' cannot conform to the 'DistributedActor' protocol}} {{1-1=distributed }}
4539
nonisolated var id: AnyActorIdentity {
@@ -58,7 +52,6 @@ actor A2: DistributedActor {
5852
}
5953
}
6054

61-
@available(SwiftStdlib 5.5, *)
6255
class C2: DistributedActor {
6356
// expected-error@-1{{non-actor type 'C2' cannot conform to the 'Actor' protocol}}
6457
// expected-error@-2{{non-final class 'C2' cannot conform to 'Sendable'; use '@unchecked Sendable'}}
@@ -77,7 +70,6 @@ class C2: DistributedActor {
7770
}
7871
}
7972

80-
@available(SwiftStdlib 5.5, *)
8173
struct S2: DistributedActor {
8274
// expected-error@-1{{non-class type 'S2' cannot conform to class protocol 'DistributedActor'}}
8375
// expected-error@-2{{non-class type 'S2' cannot conform to class protocol 'AnyActor'}}

test/Distributed/distributed_actor_basic.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44

55
import _Distributed
66

7-
@available(SwiftStdlib 5.5, *)
87
distributed actor DA {
98
}
109

11-
@available(SwiftStdlib 5.5, *)
1210
distributed actor First {
1311
distributed func one(second: Second) async throws {
1412
try await second.two(first: self, second: second)
1513
}
1614
}
1715

18-
@available(SwiftStdlib 5.5, *)
1916
distributed actor Second {
2017
distributed func two(first: First, second: Second) async {
2118
try! await first.one(second: self)
@@ -24,15 +21,13 @@ distributed actor Second {
2421

2522
// ==== ------------------------------------------------------------------------
2623

27-
@available(SwiftStdlib 5.5, *)
2824
extension First {
2925
@_dynamicReplacement (for :_remote_one(second:))
3026
nonisolated func _impl_one(second: Second) async throws {
3127
fatalError()
3228
}
3329
}
3430

35-
@available(SwiftStdlib 5.5, *)
3631
extension Second {
3732
@_dynamicReplacement (for :_remote_two(first:second:))
3833
nonisolated func _impl_two(first: First, second: Second) async throws {

test/Distributed/distributed_actor_is_experimental.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
actor SomeActor {}
77

8-
@available(SwiftStdlib 5.5, *)
98
distributed actor DA {}
109
// expected-error@-1{{'distributed' modifier is only valid when experimental distributed support is enabled}}
1110

12-
@available(SwiftStdlib 5.5, *)
1311
distributed actor class DAC {}
1412
// expected-error@-1{{'distributed' modifier is only valid when experimental distributed support is enabled}}
1513
// expected-error@-2{{keyword 'class' cannot be used as an identifier here}}
@@ -27,7 +25,6 @@ actor A {
2725
}
2826
}
2927

30-
@available(SwiftStdlib 5.5, *)
3128
distributed actor DA2 {
3229
// expected-error@-1{{'distributed' modifier is only valid when experimental distributed support is enabled}}
3330
func normal() async {}

0 commit comments

Comments
 (0)