Skip to content

init has different actor isolation from overriden - but neither exists #84644

@mattneub

Description

@mattneub

Description

Compiler error if both a class and its subclass have no explicit initializers.

Reproduction

Make a new Xcode project, turn on Swift 6 along with all the trimmings (approachable concurrency, default actor isolation to MainActor).

class Thing {} class SubThing: Thing {} 

Compiler: "Main actor-isolated initializer 'init()' has different actor isolation from nonisolated overridden declaration"

Expected behavior

It should just compile. There is no there there, so what's the problem?

Environment

Xcode Version 26.0 (17A324)

% swiftc -version swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1) Target: arm64-apple-macosx26.0 

Additional information

The fact that there is no init seems to be the problem. If you add init() {} to Thing, the error goes away. It is as if a class has an implicit init which has not gotten the memo about everything being main actor isolated by default.

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