I'm trying to migrate my fairly large application to Swift Concurrency. I've have a class marked as @MainActor
that sub-classes a 3rd party abstract class that is not migrated to Swift Concurrency.
I get the following error:
Main actor-isolated class 'MyClass' has different actor isolation from nonisolated superclass 'OtherAbstractClass'; this is an error in the Swift 6 language mode
My class needs to be MainActor as it uses other code that is required to be on the MainActor.
I can't see how to suppress this warning, I know as a guarantee that the abstract class will always be on the main thread so I need a way of telling the compiler that when I don't own the 3rd party code.
import OtherAbstractModule
@MainActor
class MyClass: OtherAbstractClass {
....
}
How can I satisfy the compiler in this case?
The Swift open source project is considering lifting this limitation in the future, but I don't know if or when that change might reach an Xcode near you. For now, you will have to isolate the individual members with @MainActor
and leave the type as a whole non-isolated.