Skip to content

Add opt-in exactLiteral version requirements#9812

Open
bc-lee wants to merge 6 commits into
swiftlang:mainfrom
bc-lee:feature/exact-literal-version
Open

Add opt-in exactLiteral version requirements#9812
bc-lee wants to merge 6 commits into
swiftlang:mainfrom
bc-lee:feature/exact-literal-version

Conversation

@bc-lee
Copy link
Copy Markdown
Contributor

@bc-lee bc-lee commented Mar 15, 2026

Proposal: swiftlang/swift-evolution#3188

Motivation:

SwiftPM currently ignores SemVer build metadata when matching exact version
requirements. This change adds an opt-in way to match a full version identifier
literally, including build metadata.

Modifications:

  • Add exactLiteral requirement APIs for source-control and registry
    dependencies.
  • Preserve the new requirement through manifest and package models.
  • Update resolution to honor literal matches for metadata-distinct versions.

Result:

Packages can now write requirements such as .exactLiteral("1.0.0+debug")
without changing existing .exact(...) or range semantics.

bc-lee added 6 commits March 15, 2026 17:01
Introduce the PackageDescription surface for exactLiteral requirements
for source-control and registry dependencies. Downstream manifest
loading remains explicitly unimplemented for this new case for now,
using fatalError stubs where exhaustiveness requires follow-up work.
Teach manifest loading and package-model conversions to preserve
exactLiteral requirements for source-control and registry dependencies.
This includes the package-model requirement cases,
equality/hash/encoding behavior, manifest source generation, and focused
loading and round-trip tests.

Resolver semantics remain unchanged in this step.
Add exactLiteral to VersionSetSpecifier, wire exactLiteral requirements
into PackageGraph constraints, and cover the new set behavior with
focused tests. Include the minimal diagnostic and PubGrub switch updates
needed for the new requirement kind to compile cleanly, while deferring
resolver behavior changes to later commits.
Teach source-control and registry package containers to preserve SemVer
build-metadata variants as distinct candidates while keeping semantic
exact selection deterministic. Add focused workspace coverage for
source-control lookup, registry ordering, and Package.resolved metadata
preservation.
Keep exactLiteral requirements intact through PubGrub decision making so
the resolver preserves metadata-distinct selections and reports
conflicts with the full requested identifiers. Add focused resolver
coverage for literal selection and conflict reporting.
Preserve metadata-bearing Package.resolved pins as literal selections
when PubGrub applies pin constraints or checks pin availability. Add a
focused resolver regression test that distinguishes metadata variants by
their full version description.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants