ibex10
1
When referencing an actor's method's type, the compiler issues the following error.
let g = ActorType.f (i:) // Error: Call to actor-isolated instance method 'f(i:)' in a synchronous main actor-isolated context
But, there is no such error if the type is class:
let f = ClassType.f (i:) // Okay
Details
@main
enum TypeOfFunction {
static func main () async throws {
let f = ClassType.f (i:) // Okay
print ("type of class function is", type (of: f))
let g = ActorType.f (i:) // Error: Call to actor-isolated instance method 'f(i:)' in a synchronous main actor-isolated context
print ("type of actor function is", type (of: g))
}
}
actor ActorType {
func f (i: Int) -> Int {i}
}
class ClassType {
func f (i: Int) -> Int {i}
}