File tree Expand file tree Collapse file tree 2 files changed +62
-1
lines changed Expand file tree Collapse file tree 2 files changed +62
-1
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift -target %target-cpu-apple-macosx10.15 -enable-experimental-feature TypeWrappers -parse-as-library -emit-library -emit-module-path %t/type_wrapper_defs.swiftmodule -module-name type_wrapper_defs %S/Inputs/type_wrapper_defs.swift -o %t/%target-library-name(type_wrapper_defs)
3
+ // RUN: %target-build-swift -target %target-cpu-apple-macosx10.15 -ltype_wrapper_defs -module-name main -I %t -L %t %s -o %t/main %target-rpath(%t)
4
+ // RUN: %target-codesign %t/main
5
+ // RUN: %target-run %t/main %t/%target-library-name(type_wrapper_defs) | %FileCheck %s
6
+
7
+ // REQUIRES: executable_test
8
+ // REQUIRES: asserts
9
+ // REQUIRES: concurrency
10
+
11
+ // rdar://76038845
12
+ // REQUIRES: concurrency_runtime
13
+ // UNSUPPORTED: back_deployment_runtime
14
+
15
+ // REQUIRES: OS=macosx
16
+
17
+ import type_wrapper_defs
18
+
19
+ @Wrapper
20
+ public actor Actor {
21
+ public var name : String
22
+ @PropWrapper public var age : Int ? = nil
23
+
24
+ public func setAge( _ newAge: Int ) async {
25
+ age = newAge
26
+ }
27
+ }
28
+
29
+ let a = Actor ( name: " Arhtur Dent " )
30
+ await print ( a. name)
31
+ // CHECK: in getter
32
+ // CHECK-NEXT: Arhtur Dent
33
+ await print ( a. age)
34
+ // CHECK: in getter
35
+ // CHECK-NEXT: nil
36
+
37
+ await a. setAge ( 30 )
38
+ // CHECK: in getter
39
+ // CHECK-NEXT: in setter => PropWrapper<Optional<Int>>(value: Optional(30))
40
+
41
+ await print ( a. age)
42
+ // CHECK: in getter
43
+ // CHECK-NEXT: 30
Original file line number Diff line number Diff line change 1
- // RUN: %target-typecheck-verify-swift -enable-experimental-feature TypeWrappers
1
+ // RUN: %target-typecheck-verify-swift -disable-availability-checking - enable-experimental-feature TypeWrappers
2
2
3
3
// REQUIRES: asserts
4
4
@@ -380,3 +380,21 @@ func testDeclarationsWithUnmanagedProperties() {
380
380
381
381
_ = OnlyLazyLetAndComputed ( name: " Arthur Dent " ) // Ok
382
382
}
383
+
384
+ func testActors( ) async {
385
+ @NoopWrapper
386
+ actor Person {
387
+ var name : String
388
+ // expected-note@-1 {{mutation of this property is only permitted within the actor}}
389
+ var age : Int
390
+ // expected-note@-1 {{mutation of this property is only permitted within the actor}}
391
+ }
392
+
393
+ let person = Person ( name: " Arthur Dent " , age: 30 )
394
+
395
+ _ = await person. name
396
+ _ = await person. age
397
+
398
+ person. name = " NoName " // expected-error {{actor-isolated property 'name' can not be mutated from a non-isolated context}}
399
+ person. age = 0 // expected-error {{actor-isolated property 'age' can not be mutated from a non-isolated context}}
400
+ }
You can’t perform that action at this time.
0 commit comments