I have a class that subclasses NSTextAttachmentCell. It overrides the cellSize() method that comes from NSTextAttachmentCellProtocol. Now that I'm transitioning to using swift concurrency, I have errors when I access any properties or methods from the cellSize method. This is because NSTextAttachmentCell is annotated with @MainActor, but the protocol is not.
class MyCell: NSTextAttachmentCell {
override func cellSize() -> NSSize {
doSomething(with: state) // Error: `state` is actor-isolated
}
}
I tried using @preconcurrency import AppKit, but it had no effect.
This sounds silly, but I also tried creating a MainActor protocol that inherits from NSTextAttachmentCellProtocol and then conforming my cell subclass to that. As expected, no change.
I assume NSTextAttachmentCellProtocol will be annotated with @MainActor at some point, but I don't see a way around the error until then (besides reducing the strict concurrency checking build setting).