Declare MainExecutor conformance explicitly for GLibMainExecutor

swift run/build failed on this toolchain (stock swift.org 6.3.3 aarch64 Linux) with:

  GLibMainExecutor.swift:227: error: value of type 'GLibMainExecutor' does
  not conform to specified type 'MainExecutor'

despite the class already implementing every method MainExecutor requires
(enqueue, run, runUntil, stop) via its separate RunLoopExecutor and
SerialExecutor conformances. Root cause: Swift protocol refinement is
one-directional. MainExecutor : RunLoopExecutor, SerialExecutor adds no
requirements of its own, but conforming to the two parent protocols
separately does not implicitly satisfy the refined protocol - the
existential conversion to 'any MainExecutor' needs an explicit conformance
declaration for MainExecutor itself, confirmed with a minimal repro against
the stdlib's private _Concurrency interface.

Fix: add 'extension GLibMainExecutor: MainExecutor {}' (no new members
needed - the class already satisfies every requirement), scoped inside the
existing '#if canImport(Glibc)' block. Kept off Darwin deliberately:
MainExecutor carries a much higher Darwin '@available' floor than this
package targets, and GLibMainExecutor is only ever installed as the process
main executor on Linux (DarwinMainQueuePump is the Apple equivalent) - on
Darwin it is used solely as a plain SerialExecutor for individual actors,
which does not require MainExecutor conformance.

Verified: 'swift build' and 'swift test' both clean (286/286 tests) in this
package standalone, and a full 'swift build' of Luminate against this
checkout via 'swift package edit' succeeds end to end.
This commit is contained in:
Brendan Szymanski 2026-08-12 21:45:03 -04:00
parent e0dd29297a
commit e9e56e28d3

View file

@ -216,6 +216,18 @@ nonisolated func portico_executor_destroy_notify(_ data: UnsafeMutableRawPointer
} }
#if canImport(Glibc) #if canImport(Glibc)
/// `MainExecutor` refines `RunLoopExecutor & SerialExecutor` without adding
/// further requirements, but Swift protocol refinement is one-directional:
/// conforming to the two parent protocols separately does not implicitly
/// satisfy the refined protocol, so the existential conversion to
/// `any MainExecutor` below needs this explicit (requirement-free)
/// conformance declaration. Scoped to Linux because `MainExecutor` carries a
/// high Darwin `@available` floor that `GLibMainExecutor` should not
/// inherit on Apple platforms, where it is used only as a plain
/// `SerialExecutor` and never installed as the process main executor.
extension GLibMainExecutor: MainExecutor {}
// MARK: - Factory // MARK: - Factory
/// Installs ``GLibMainExecutor`` as the process main executor via the /// Installs ``GLibMainExecutor`` as the process main executor via the