1
+ // RUN: %target-swift-frontend -emit-silgen %s -module-name accessors -swift-version 5 -enable-experimental-concurrency | %FileCheck --enable-var-scope %s
2
+ // REQUIRES: concurrency
3
+
4
+ class C {
5
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1CC16prop_asyncThrowsSivg : $@convention(method) @async (@guaranteed C) -> (Int, @error Error) {
6
+ var prop_asyncThrows : Int {
7
+ get async throws { 0 }
8
+ }
9
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1CC10prop_asyncSivg : $@convention(method) @async (@guaranteed C) -> Int {
10
+ var prop_async : Int {
11
+ get async { 1 }
12
+ }
13
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1CC11prop_throwsSivg : $@convention(method) (@guaranteed C) -> (Int, @error Error) {
14
+ var prop_throws : Int {
15
+ get throws { 2 }
16
+ }
17
+ }
18
+
19
+ struct S {
20
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1SVyS2icig : $@convention(method) @async (Int, S) -> Int {
21
+ subscript( _ s : Int ) -> Int {
22
+ get async { 0 }
23
+ }
24
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1SVySiSdcig : $@convention(method) (Double, S) -> (Int, @error Error) {
25
+ subscript( _ s : Double ) -> Int {
26
+ get throws { 0 }
27
+ }
28
+ }
29
+
30
+ enum E {
31
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1EOyS2icig : $@convention(method) @async (Int, E) -> (Int, @error Error) {
32
+ subscript( _ e : Int ) -> Int {
33
+ get async throws { 0 }
34
+ }
35
+ }
36
+
37
+ actor A {
38
+ // CHECK-DAG: sil hidden [transparent] [ossa] @$s9accessors1AC10normalPropSivg : $@convention(method) (@guaranteed A) -> Int {
39
+ var normalProp : Int = 0
40
+ // CHECK-DAG: sil hidden [ossa] @$s9accessors1AC12computedPropSivg : $@convention(method) (@guaranteed A) -> Int {
41
+ var computedProp : Int { get { 0 } }
42
+
43
+ // CHECK-LABEL: sil hidden [ossa] @$s9accessors1AC9asyncPropSivg : $@convention(method) @async (@guaranteed A) -> Int {
44
+ // CHECK: bb0([[SELF:%[0-9]+]] : @guaranteed $A):
45
+ // CHECK: hop_to_executor [[SELF]] : $A
46
+ // CHECK: } // end sil function '$s9accessors1AC9asyncPropSivg'
47
+ var asyncProp : Int {
48
+ get async { 0 }
49
+ }
50
+
51
+ }
52
+
53
+ // CHECK-LABEL: sil hidden [ossa] @$s9accessors19testImplicitlyAsync1aSiAA1AC_tYF : $@convention(thin) @async (@guaranteed A) -> Int {
54
+ // CHECK: hop_to_executor
55
+ // CHECK: apply {{%[0-9]+}}({{%[0-9]+}}) : $@convention(method) (@guaranteed A) -> Int
56
+ // CHECK: hop_to_executor
57
+ // CHECK: } // end sil function '$s9accessors19testImplicitlyAsync1aSiAA1AC_tYF'
58
+ func testImplicitlyAsync( a : A ) async -> Int {
59
+ return await a. computedProp
60
+ }
61
+
62
+
63
+ // CHECK-LABEL: sil hidden [ossa] @$s9accessors15testNormalAsync1aSiAA1AC_tYF : $@convention(thin) @async (@guaranteed A) -> Int {
64
+ // CHECK: apply {{%[0-9]+}}({{%[0-9]+}}) : $@convention(method) @async (@guaranteed A) -> Int
65
+ // CHECK: } // end sil function '$s9accessors15testNormalAsync1aSiAA1AC_tYF'
66
+ func testNormalAsync( a : A ) async -> Int {
67
+ return await a. asyncProp
68
+ }
0 commit comments