Hey guys,
since the new default actor isolation, i wanted to try to set my project to MainActor default actor.
After changing the setting i was getting basically an error for every struct that has Codable in it.
My code:
extension MyTestActor {
struct Structs {}
}
extension MyTestActor.Structs {
struct MyTestStruct: Codable {
var test: String
}
}
for this code i was getting this error
Circular referenceSourceKit
Test.swift(19, 12): Through reference here
Test.swift(19, 12): Through reference here
Test.swift(19, 12): Through reference here
Conformance of 'MyTestActor.Structs.MyTestStruct' to protocol 'Encodable' crosses into main actor-isolated code and can cause data racesSourceKitconformance-isolation
Test.swift(19, 22): Isolate this conformance to the main actor with '@MainActor'
Test.swift(19, 22): Turn data races into runtime errors with '@preconcurrency'
Test.swift(19, 22): Main actor-isolated instance method 'encode(to:)' cannot satisfy nonisolated requirement (Mana.MyTestActor.Structs.MyTestStruct.encode)
although what is funny.. if i change my code to this code, it suddenly is not throwing any error anymore, although i just removed the nesting of the structs.. why does this happen?
extension MyTestActor {
struct Structs {}
}
extension MyTestActor {
struct MyTestStruct: Codable {
var test: String
}
}