Skip to content

Enable incremental migration for argument swap - #2806

Merged
natebosch merged 2 commits into
masterfrom
has2
Oct 28, 2026
Merged

natebosch merged 2 commits into
masterfrom
has2

Conversation

@natebosch

Copy link
Copy Markdown
Member

Towards #2616

Landing ahead of #2758

Add a has2 extension method on Subject which takes the name
argument before the extract callback. This is the argument order that
has will eventually use. It's more common in Dart for a callback
argument to be trailing, and it reads better with the name first.

This package needs to roll to mono repos where an atomic fix to usage
sites is more brittle than incremental fixes. Instead of swapping the
arguments to has in one breaking change, roll this version and migrate
usages to has2. Then swap the arguments to has, migrate usages back,
and remove has2. All of these steps will land before the next publish
to pub.

Migrate usages in this repo to has2, and update the checks_codegen
builder to generate has2 calls.

Towards #2616

Landing ahead of #2758

Add a `has2` extension method on `Subject` which takes the `name`
argument before the `extract` callback. This is the argument order that
`has` will eventually use. It's more common in Dart for a callback
argument to be trailing, and it reads better with the name first.

This package needs to roll to mono repos where an atomic fix to usage
sites is more brittle than incremental fixes. Instead of swapping the
arguments to `has` in one breaking change, roll this version and migrate
usages to `has2`. Then swap the arguments to `has`, migrate usages back,
and remove `has2`. All of these steps will land before the next publish
to pub.

Migrate usages in this repo to `has2`, and update the `checks_codegen`
builder to generate `has2` calls.
@natebosch
natebosch requested a review from a team as a code owner October 26, 2026 23:57
@natebosch
natebosch requested a review from kevmoo October 26, 2026 23:57
@github-actions github-actions Bot added the package:checks Issues related to pkg:checks label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

@natebosch
natebosch requested a review from jonasfj October 28, 2026 00:43
@jonasfj

jonasfj commented Oct 28, 2026

Copy link
Copy Markdown
Member

You could also just make a hard break, it'll be a bit complicated to migrate a few places. But checks isn't 1.0.0 yet.

@natebosch

Copy link
Copy Markdown
Member Author

You could also just make a hard break

It'll be a hard break by the time it's published to pub. This is solely to remove complications from internal rolls.

@natebosch
natebosch merged commit 434cf2f into master Oct 28, 2026
119 of 120 checks passed
@natebosch
natebosch deleted the has2 branch October 28, 2026 16:06
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Oct 29, 2026
Revisions updated by `dart tools/rev_sdk_deps.dart test`.

test (https://github.com/dart-lang/test/compare/5967927..6d74720):
  6d747209  Wed Oct 28 15:12:45 2026 -0700  Nate Bosch  Fix a race in an expanded reporter retry test (dart-lang/test#2810)
  434cf2fc  Wed Oct 28 09:06:26 2026 -0700  Nate Bosch  Enable incremental migration for argument swap (dart-lang/test#2806)

Change-Id: Ifcb0f113940380b788492f3fed829792ba0b7676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/570662
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Kevin Moore <[email protected]>
Commit-Queue: Kevin Moore <[email protected]>
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Oct 29, 2026
`package:checks` is swapping the argument order of `Subject.has` so the
description comes before the extractor. To allow incremental migration,
dart-lang/test#2806 added `has2(String name, R Function(T) extract)`
alongside `has(R Function(T) extract, String name)`.

This is the first step of a multi-step migration that ends back at `has`:

1. Move callers from `has(extract, name)` to `has2(name, extract)` (this
   change).
2. Change `has` in `package:checks` to take `(name, extract)`.
3. Move callers from `has2` back to `has`, then remove `has2`.

Rewrite all 52 `has` calls in `pkg/analyzer/test` and
`pkg/dartpad_worker/test` to `has2`, swapping the arguments. The calls
were found and rewritten with an analyzer-based codemod that only touches
invocations resolving to `package:checks`.

All packages that use `package:checks` list it in `dev_dependencies` with
an `any` constraint, so no pubspec changes are needed.

Change-Id: I845e9a36988ca9eecc8bf1f5b2db45c4eaa41f2c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/571201
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Commit-Queue: Nate Bosch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:checks Issues related to pkg:checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants