-
Notifications
You must be signed in to change notification settings - Fork 185
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
Scalameta 4.5.0 (was 4.4.35) #1556
Conversation
I'll merge this and open a PR on simulacrum-scalafix with the resulting nightly to follow-up on this regression. |
@@ -7,7 +7,7 @@ import scalafix.v0._ | |||
|
|||
object DenotationOps { | |||
val defaultDialect: Dialect = | |||
dialects.Scala212.copy(allowMethodTypes = true, allowTypeLambdas = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed the breaking change, identified the root cause and updated the rule code in typelevel/simulacrum-scalafix@04f557f. However, this brings questions about compatibility. Rule authorsShould we signal this change to rule authors dealing with Running rules built against newer scalafix versions with older scalafix versionsRules relying on scalafix/scalafix-interfaces/src/main/java/scalafix/internal/interfaces/ScalafixCoursier.java Lines 69 to 76 in 8bd700f
This is not new (rules matching on Scala3-specific trees such as To mitigate this problem, I suggest we provide an actionable error message when encountering linking exceptions ("a more recent versions of scalafix is needed to run that rule"). This will improve the scalafix user experience if/when new trees are added in scalameta in the future. Running rules built against older scalafix versions with newer scalafix versionsConversely, running rules built against older versions of scalafix might miss some trees (silently I believe?) when ran on the upcoming version of scalafix since they will be exposed to unexpected To mitigate that, we could issue a warning when detecting that external rules are built against a different minor version of scalafix: "running external scalafix rules built for an earlier version - correctness is not guaranteed so downgrade the scalafix version or ask the rule author to release a new version". This would be very verbose though, and seems to be very specific to scalameta/scalameta#2601 so I would suggest not to do anything. |
Could we have a requirement in the rules for the minimal Scalafix version? I would even fail in that situation if possible.
It should miss silently in most cases unless any rule depends on a very specific path of tree nodes. I think most rules traverse tree until they find what is needed, so they would skip unknown nodes. We could issue a warning in this case for sure. |
Thanks for chiming-in @tgodzik ! Running rules built against newer scalafix versions with older scalafix versions
This can already be done on the rule side by checking https://www.javadoc.io/doc/ch.epfl.scala/scalafix-core_2.12/0.9.34/scalafix/Versions$.html. I'll experiment this in typelevel/simulacrum-scalafix#194. For the long term, I am not convinced it's a good idea to let the client handle that (with or without a specific API allowing them to declare a version), as most of the rule authors wouldn't know which minimum scalafix/scalameta version to use. Thinking more about it, the safest would be to fail if scalafix-core tries to load rules built against a future version of it. Some community clients (mill, maven) might be lagging a few scalafix-core versions behind, but so do rule authors, so I think situations where a user cannot run a recent rule because his client is too old will be rare. Running rules built against older scalafix versions with newer scalafix versions
I think so too, yet typelevel/simulacrum-scalafix@04f557f#diff-e210d889e0da3ec13e31e14a8b9500501669f3ab159725bfcce76bae07e2668aL37 is a counter-example where we have false negative matches. It's hard to tell how common that is.
The problem is that this warning would then be issued for any community rule, until a version published against the latest scalafix is released. But I don't see any other way. |
I think we should bite the bullet on that. It's a (admittedly regrettable) one-time annoyance for a significant long-term benefit. |
In the Scala 2 community build, I noticed that 1) this upgrade hasn't happened here yet, and 2) it requires a small source change (because the deprecated
allowMethodTypes
was removed).And then also I'm seeing failing tests downstream in simulacrum-scalafix, at https://scala-ci.typesafe.com/job/scala-2.13.x-jdk11-integrate-community-build/3535/artifact/logs/simulacrum-scalafix-build.log :
I don't know what to make of this. Regression in scalameta? Something in scalafix that needs to be adjusted for the new scalameta version? Or is it just something that the simulacrum-scalafix people (@sh0hei maybe?) need to adjust in their test suite?
Properly investigating isn't really something I can take on myself.
Regardless, opening this PR to get the ball rolling. (It isn't easy for the simulacrum-scalafix folks to investigate unless they have a scalafix release to use.)