Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with using being added erroneously #31

Merged
merged 7 commits into from
Oct 8, 2024

Conversation

mrdziuban
Copy link
Contributor

@mrdziuban mrdziuban commented Oct 7, 2024

Fixes #30

It turned out this was only an issue on later scalafix/scalameta versions, so I had to upgrade dependencies to actually reproduce and fix it.

The commit with the actual fix is mrdziuban@c6be468.

The other changes were to address things related to the scalafix upgrade:

  • Resolve deprecation warnings
  • Use templ.body.children in the SemiAuto rule instead of just templ.children
    • In the old scalafix version, templ.children returned all the statements within the template, but now it just returns a List with one element -- the template's body -- so we need to look at the children of the body

EDIT:

This also fixes an issue where using is added to code that's calling a function returned by a method that takes using parameters. See example code in #31 (comment)

Copy link
Member

@hamnis hamnis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Looks good to me, leaving merging to @ingarabr

@mrdziuban
Copy link
Contributor Author

There's one more bug I'm going to try to address here, where the using keyword is incorrectly added when calling a function returned by a method with using parameters.

For example, this code:

def test(using i: Int): String => String = s => s

given i: Int = 1
test("")

is rewritten to:

def test(using i: Int): String => String = s => s

given i: Int = 1
// Note the `using` keyword is added here but results in a compile error
test(using "")

@mrdziuban mrdziuban changed the title Prevent duplicate using keywords Fix issues with using being added erroneously Oct 7, 2024
@mrdziuban
Copy link
Contributor Author

Fixed that bug and updated the PR title and description to match

@ingarabr
Copy link
Contributor

ingarabr commented Oct 8, 2024

Looks good to me. Thank you for updating dependencies and deprecated code. Much appreciated :)

@hamnis hamnis merged commit 295205c into arktekk:main Oct 8, 2024
3 checks passed
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.

GivenAndUsing rule duplicates using keyword when explicitly passing a using param
3 participants