I'm auditing a library for concurrency and it contains a SwiftUI view that holds an observed object (pinning it to the main actor), and conditionally conforms to DynamicViewContent
, which contains a non-main actor requirement, causing the following warning:
class VM: ObservableObject {}
struct Thing<Content: View>: View {
@ObservedObject var vm: VM
let body: Content
}
extension Thing: DynamicViewContent where Content: DynamicViewContent {
var data: Content.Data { self.body.data } ⚠️
}
Main actor-isolated property 'data' cannot be used to satisfy nonisolated protocol requirement
Is this a SwiftUI bug that should be fixed? Should DynamicViewContent
have the same @_Concurrency.MainActor(unsafe)
annotation on data
?
And is there any way to silence this warning? @preconcurrency
isn't helping here.