I'm implementing some kind of request manager, based on protocols conformance and I faced with unexpected behaviour:
import Foundation protocol Foosyncable: AnyObject { func request() } protocol Fooasyncable: AnyObject { func request() async } protocol Fooable: Foosyncable, Fooasyncable {} class Foo: Fooable { func request() { print("request") } func request() async { print("request async") } } class Fooooooo { let f: Fooable init() { f = Foo() } func boo() async throws { await f.request() } } let f = Fooooooo() Task { try await f.boo() } Output of code above is 'request', instead expected 'request async'. I try to figure out why async method isn't call in that case.
If I change let f: Fooable to let f: Foo, it works as expected.
In other hand, when I remove await from call of f.boo(), I got error: Expression is ‘async’ but is not marked with ‘await’, which is more weird.