mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SE-0466] Don't infer @MainActor on types conforming to Sendable
When the default isolation is main-actor, don't infer @MainActor for a type that conforms to a protocol P in its primary definition when P inherits from Sendable. Such types should remain non-isolated because they're highly unlikely to be able to implement the P conformance (which cannot be isolated). Put this feature behind a new experimental flag, SendableProhibitsMainActorInference. Implements rdar://151029300
This commit is contained in:
@@ -532,6 +532,10 @@ EXPERIMENTAL_FEATURE(DefaultIsolationPerFile, false)
|
||||
/// Enable @_lifetime attribute
|
||||
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(Lifetimes, true)
|
||||
|
||||
/// Disable @MainActor inference when the primary definition of a type conforms
|
||||
/// to SendableMetatype (or Sendable).
|
||||
EXPERIMENTAL_FEATURE(SendableProhibitsMainActorInference, true)
|
||||
|
||||
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
|
||||
#undef EXPERIMENTAL_FEATURE
|
||||
#undef UPCOMING_FEATURE
|
||||
|
||||
Reference in New Issue
Block a user