The build fails with the error saying Actor-isolated instance method 'testFunction()' cannot be used to satisfy nonisolated protocol requirement.
But isn't the whole purpose of actor thread safety and preventing data races? If so, where is the data race in the above code or conformance to protocol in general?
You want to either prescribe that it will be an actor that implements the protocol (and the testFunction then would be isolated to the actor), or mark the testFunction as nonisolated in your actor implementation (if you don't want the isolation).
Right now, you define a protocol which does not have any isolation prescribed for the testFunction, but implement it in the context of an actor that have isolation for its functions by default - thus the warning.
So, either:
protocol TestProtocol: Actor {
func testFunction()
}
actor TestClass: TestProtocol {
func testFunction() {
}
}
should work depending on what you wish (likely the first).
So the compiler is not overly strict here, it forces you to explain whether you want the function isolated to the actor (version 1), or nonisolated (version 2), as the original version you have is ambiguous.
For reference, this class of problem, known as a "protocol conformance isolation mismatch" comes up a lot. There's a whole section devoted to it in the concurrency migration guide. Though the guide doesn't specifically cover actors, I think the discussion there could still be helpful.