Skip to content

Fix compilation on nightly-main Swift, which has new optional type inference#900

Merged
simonjbeaumont merged 2 commits intoswift-server:mainfrom
simonjbeaumont:sb/nightly-workaround
Mar 24, 2026
Merged

Fix compilation on nightly-main Swift, which has new optional type inference#900
simonjbeaumont merged 2 commits intoswift-server:mainfrom
simonjbeaumont:sb/nightly-workaround

Conversation

@simonjbeaumont
Copy link
Collaborator

Motivation

Swift nightly-main has regressed how existential types interact with generic parameter inference through optionals. startRequestSpan<T>(tracer: T?) is called with self.anyTracer, typed (any Sendable)?. The compiler previously inferred T = any Sendable, but nightly-main now rejects this, producing:

error: value of optional type '(any Sendable)?' must be unwrapped to a value of type 'any Sendable'

Modification

Replace the generic parameter <T> with an explicit (any Sendable)? parameter type. The generic existed solely to erase the Tracer protocol from the signature so that non-availability-guarded code could call the method. Accepting (any Sendable)? directly serves the same purpose.

There is no performance impact: the call site already passes an existential-typed value, so T was always inferred as any Sendable and never specialized to a concrete type. The force-cast to (any Tracer)? inside the function is unchanged.

Result

Fixes compilation on Swift nightly-main. No behavioural change.

Related

swiftlang/swift#88058

@simonjbeaumont simonjbeaumont added the 🔨 semver/patch No public API change. label Mar 24, 2026
@simonjbeaumont simonjbeaumont enabled auto-merge (squash) March 24, 2026 14:23
@simonjbeaumont simonjbeaumont merged commit 3a5b74a into swift-server:main Mar 24, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants