Skip to content

Protocol does not inherit actor isolation from class constraint #76906

@hamtiko

Description

@hamtiko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions