-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
Consider a protocol with a class constraint that is actor-isolated. Since the protocol can only be conformed to by subclasses of the actor-isolated class, its conformances should inherently be actor-isolated. However, the compiler does not treat the protocol as isolated and raises the following warning in the conforming class:
Main actor-isolated property 'property' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
.
The only way to resolve this warning is to explicitly mark the protocol itself as isolated.
Reproduction
protocol MyProto: UIViewController {
var property: String { get }
}
class MyVc: UIViewController, MyProto {
var property: String = "Hello" // warning: Main actor-isolated property 'property' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode
}
Expected behavior
The protocol should automatically inherit actor isolation from its class constraint, eliminating the need to manually declare the protocol as isolated.
Environment
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
Additional information
No response