Skip to content

Commit c2eda02

Browse files
committed
Adding test case for implicit async funcs
This patch adds a test to verify that functions that are implicitly async also are reported as errors when passing data inout.
1 parent a09224d commit c2eda02

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/Concurrency/actor_inout_isolation.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,26 @@ extension TestActor {
108108
await position.setComponents(x: &value1, y: &value2)
109109
}
110110
}
111+
112+
// Check implicit async testing
113+
actor class DifferentActor {
114+
func modify(_ state: inout Int) {}
115+
}
116+
117+
extension TestActor {
118+
func modify(_ state: inout Int) {}
119+
120+
// Actor state passed inout to implicitly async function on an actor of the
121+
// same type
122+
func modifiedByOtherTestActor(_ other: TestActor) async {
123+
//expected-error@+1{{actor-isolated property 'value2' cannot be passed 'inout' to asynchronous function}}
124+
await other.modify(&value2)
125+
}
126+
127+
// Actor state passed inout to an implicitly async function on an actor of a
128+
// different type
129+
func modifiedByOther(_ other: DifferentActor) async {
130+
//expected-error@+1{{actor-isolated property 'value2' cannot be passed 'inout' to asynchronous function}}
131+
await other.modify(&value2)
132+
}
133+
}

0 commit comments

Comments
 (0)