-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
When using default actor isolation of MainActor, having a protocol which conforms to Equatable forces workarounds on conforming types.
Note that the majority of cases were already fixed (see: #82384)
So perhaps this is something unique to Equatable.
Reproduction
protocol P1: Equatable { }
struct S1: P1 { }
// Error: Conformance of 'S1' to protocol 'P1' crosses into main actor-isolated code an can cause data races
struct S1Workaround: @MainActor P1 { } // OK
// Another potential workaround if `Equatable` conformance can be moved to the conforming type.
protocol P2 { }
struct S2: Equatable, P2 { } // OKExpected behavior
Similar to what was fixed previously (example below), it should be possible to have a protocol conform to Equatable without requiring conforming types to have to specify @MainActor
// This used to fail with the same error, but has been addressed
protocol P1: Codable { }
struct S1: P1 { }
Environment
6.2 (swiftlang-6.2.0.16.14 clang-1700.3.16.4)
Additional information
No response
bartcone
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels