-
Notifications
You must be signed in to change notification settings - Fork 187
DisableSyntax
: Add special case for asInstanceOf[Matchable]
in Scala 3
#2245
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
base: main
Are you sure you want to change the base?
Conversation
While trying to execute the test via sbt shell, I keep getting the following: [IJ]expect3_3_6Target3_3_6 / testOnly -- -z DisableSyntax
[error] stack trace is suppressed; run 'last integration3_3_6 / update' for the full output
[error] (integration3_3_6 / update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] file:/C:/Users/G15/.m2/repository/com/github/luben/zstd-jni/1.5.6-3/zstd-jni-1.5.6-3.jar: not found: C:\Users\G15\.m2\repository\com\github\luben\zstd-jni\1.5.6-3\zstd-jni-1.5.6-3.jar
[error] Total time: 1 s, completed 15 May 2025, 5:09:59 am Is there a quick fix for this? |
Signed-off-by: subhramit <[email protected]>
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.
Thanks for the contribution, code & test LGTM functionally. I kicked off CI and added corresponding comments.
While trying to execute the test via sbt shell, I keep getting the following:
[IJ]expect3_3_6Target3_3_6 / testOnly -- -z DisableSyntax [error] stack trace is suppressed; run 'last integration3_3_6 / update' for the full output [error] (integration3_3_6 / update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts: [error] file:/C:/Users/G15/.m2/repository/com/github/luben/zstd-jni/1.5.6-3/zstd-jni-1.5.6-3.jar: not found: C:\Users\G15\.m2\repository\com\github\luben\zstd-jni\1.5.6-3\zstd-jni-1.5.6-3.jar [error] Total time: 1 s, completed 15 May 2025, 5:09:59 amIs there a quick fix for this?
I am not familiar with this error. That dependency comes from coursier. Did you try to flush the coursier cache? You could try to reproduce the problem with the coursier cli via cs fetch com.github.luben:zstd-jni:1.5.6-3
maybe.
scalafix-rules/src/main/scala/scalafix/internal/rule/DisableSyntax.scala
Outdated
Show resolved
Hide resolved
scalafix-tests/input/src/main/scala-3/test/disableSyntax/MatchableDisableSyntax.scala
Outdated
Show resolved
Hide resolved
scalafix-tests/input/src/main/scala-3/test/disableSyntax/MatchableDisableSyntax.scala
Outdated
Show resolved
Hide resolved
scalafix-tests/input/src/main/scala-3/test/disableSyntax/MatchableDisableSyntax.scala
Outdated
Show resolved
Hide resolved
override def equals(obj: Any): Boolean = | ||
obj.asInstanceOf [ Matchable ] match { /* assert: DisableSyntax.asInstanceOf | ||
^^^^^^^^^^^^^ | ||
asInstanceOf casts are disabled, use pattern matching instead |
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.
It would be nice to have the proper message here as well - for that you need to make your token matching logic resilient to whitespaces
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 initially thought of taking a reasonable estimate of 10 tokens (thinking it'd suffice for practical purposes) and filtering whitespaces through them, but it seemed like really bad/"magic" code, so tried to implement a more general solution in c8ef86a. Let me know if it looks good.
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.
Thanks. I will see if I can think of a more idiomatic way to ignore white spaces, but probably not before next week.
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.
In case you do come up with something later and lack time, you can comment the sketch and I'd be happy to file a follow-up.
…ableDisableSyntax.scala Co-authored-by: Brice Jaglin <[email protected]>
…ableDisableSyntax.scala Co-authored-by: Brice Jaglin <[email protected]>
…ableDisableSyntax.scala Co-authored-by: Brice Jaglin <[email protected]>
… test Signed-off-by: subhramit <[email protected]>
Hi @bjaglin, thanks for taking time to look through, the comments were really helpful!
As a hack, I manually downloaded the plugin from https://repo1.maven.org/maven2/com/github/luben/zstd-jni/1.5.6-3/ and placed it at the location it was looking for. That fixed it. However, I was getting too many exceptions on Windows, so shifted to GitHub codespaces for the time being (also to run |
Signed-off-by: subhramit <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
CI seems to complain for JDK 21 at
Any idea what could be causing this? Seems unrelated at first sight. |
Most likely a race condition creating flakiness (the |
@bjaglin the checks are all green. Is there anything else to be done in the context of this PR? |
As I mentioned above, I need to review the implementation, which won't happen in the coming days because I don't have the bandwidth. |
Apologies, I misinterpreted the comment to be in the context of a later enhancement of code quality. Sure, as convenient. |
Fixes #1763
Note that the fix is based on the comment which mentions that it's acceptable to have false positives. We look at the next tokens after
asInstanceOf
to check for[Matchable]
.I am new to Scala and Scalafix, so please let me know if anything is off.