I cannot get this simple while loop with 2 conditions to compile:
actor Actor1 {
func isBusy() -> Bool { false }
}
actor Actor2 {
func isBusy() -> Bool { false }
}
let a1 = Actor1()
let a2 = Actor2()
while await a1.isBusy() && await a2.isBusy() {
// 'await' cannot appear to the right of a non-assignment operator
// 'await' in an autoclosure that does not support concurrency
// Actor-isolated instance method 'isBusy()' can not be referenced from a non-isolated context
}
while (await a1.isBusy()) && (await a2.isBusy()) {
// 'await' in an autoclosure that does not support concurrency
// Actor-isolated instance method 'isBusy()' can not be referenced from a non-isolated context
}
while await a1.isBusy() {
// One condition compiles fine
}
I agree the example looks like an anti-pattern, but my actual usage of it isn't and that's beyond the scope of this question. I simply would like to know the appropriate syntax. If the appropriate syntax doesn't work I can file a compiler bug.
You could replace && with a comma , in the first example. I think it's the @autoclosure of the rhs parameter to && which can't currently support async.