[OpenCB Project Fix] Fixes #26003: Apply -source:3.7-migration rewrite for positional using args#26009
Open
soronpo wants to merge 3 commits into
Open
[OpenCB Project Fix] Fixes #26003: Apply -source:3.7-migration rewrite for positional using args#26009soronpo wants to merge 3 commits into
using args#26009soronpo wants to merge 3 commits into
Conversation
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
92 tasks
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
using argsusing args
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a method's only parameter list is a
usingclause (e.g. from a desugared context bounddef f[A: B]), calling it positionally without theusingkeyword used to fail with an ambiguous-given error before the-rewrite -source:3.7-migrationrewrite could fire, leaving the warning's promise of an automatic rewrite unfulfilled.Extend
matchingApplyto recognize positional applications to aContextualMethodTypewhile theImplicitParamsWithoutUsingmigration is active, route them throughMigrations.implicitParams(now checkingtp.isImplicitMethodso it covers contextual params too), and skip the olderExplicitContextBoundArgumentmigration 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)