Skip to content

[OpenCB Project Fix] Fixes #26003: Apply -source:3.7-migration rewrite for positional using args#26009

Open
soronpo wants to merge 3 commits into
scala:mainfrom
soronpo:claude/fix-scala3-26003-1MpCz
Open

[OpenCB Project Fix] Fixes #26003: Apply -source:3.7-migration rewrite for positional using args#26009
soronpo wants to merge 3 commits into
scala:mainfrom
soronpo:claude/fix-scala3-26003-1MpCz

Conversation

@soronpo
Copy link
Copy Markdown
Contributor

@soronpo soronpo commented May 8, 2026

When a method's only parameter list is a using clause (e.g. from a desugared context bound def f[A: B]), calling it positionally without the using keyword used to fail with an ambiguous-given error before the -rewrite -source:3.7-migration rewrite could fire, leaving the warning's promise of an automatic rewrite unfulfilled.

Extend matchingApply to recognize positional applications to a ContextualMethodType while the ImplicitParamsWithoutUsing migration is active, route them through Migrations.implicitParams (now checking tp.isImplicitMethod so it covers contextual params too), and skip the older ExplicitContextBoundArgument migration for contextual method types — that one is a hard error past 3.5 and would prevent the rewrite from being applied.

Fixes #26003

How much have you relied on LLM-based tools in this contribution?

Extensively, but it's a small fix.

How was the solution tested?

New automated tests (including the issue's reproducer, if applicable)

claude added 2 commits May 8, 2026 13:37
When a method's only parameter list is a `using` clause (e.g. from a
desugared context bound `def f[A: B]`), calling it positionally without
the `using` keyword used to fail with an ambiguous-given error before
the `-rewrite -source:3.7-migration` rewrite could fire, leaving the
warning's promise of an automatic rewrite unfulfilled.

Extend `matchingApply` to recognize positional applications to a
`ContextualMethodType` while the `ImplicitParamsWithoutUsing` migration
is active, route them through `Migrations.implicitParams` (now
checking `tp.isImplicitMethod` so it covers contextual params too), and
skip the older `ExplicitContextBoundArgument` migration for contextual
method types — that one is a hard error past 3.5 and would prevent the
rewrite from being applied.

Fixes scala#26003

https://claude.ai/code/session_01AQvMJV76qwUJqHxM4nubZp
- tests/rewrites/i26003.check: update to match the indent-rewrite output
  the CI test command applies (`-indent` strips the `match { ... }`
  braces, leaving trailing blank lines in their place).

- matchingApply: only treat positional arguments to a `ContextualMethodType`
  as a migration candidate when the contextual clause is the *final*
  parameter list. Otherwise we'd misroute calls like
  `extension (using ee: EE) def f(retries: Int, timeout: D)` (specs2's
  `FutureAwait`) where the positional args are intended for the
  trailing regular clause, which broke `community_build_c`.

https://claude.ai/code/session_01AQvMJV76qwUJqHxM4nubZp
Two more CI fixes for the `ImplicitParamsWithoutUsing` migration when
applied to a `ContextualMethodType`:

- The `!resType.isInstanceOf[MethodOrPoly]` guard wasn't enough to keep
  the migration from misrouting `summon[Conversion[Boolean, Result]](t)`
  in specs2: `summon`'s `using` clause has a non-method `Conversion`
  result that the call applies to, so my fix was tupling `(t)` into a
  using arg and triggering a type mismatch with `Conversion`. Restrict
  the new path to method types whose `using` parameters all carry
  `ContextBoundParamName` — that's the actual user-facing case (legacy
  Scala-2-style `def f[A: B]` desugaring) the migration was added for,
  and it leaves `summon`-like single-using calls untouched.

- Update `tests/rewrites/i26003.check` to match the byte-exact rewrite
  output (no trailing blank lines — the previous extra newlines were
  formatting artifacts from the diff-message in the CI log).

https://claude.ai/code/session_01AQvMJV76qwUJqHxM4nubZp
@soronpo soronpo marked this pull request as ready for review May 8, 2026 20:54
@soronpo soronpo changed the title Fixes #26003: Apply -source:3.7-migration rewrite for positional using args [OpenCB Project Fix] Fixes #26003: Apply -source:3.7-migration rewrite for positional using args May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-rewrite -source:3.7-migration does not insert using for positional implicit args; ambiguous-given error reported instead

2 participants