-
-
Notifications
You must be signed in to change notification settings - Fork 287
Add CommandLineParserAdapter for >=2.13.9 #1634
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
Merged
simuons
merged 3 commits into
bazel-contrib:master
from
mbland:bzlmod-fix-test_util-for-scala-2.13.9
Oct 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
third_party/utils/src/test/scala/tools/cmd/Scala_2_13_9_CommandLineParser.scala
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package scala.tools.cmd; | ||
|
|
||
| // Hack due to CommandLineParser disappearing in Scala 2.13.9: | ||
| // https://github.com/scala/scala/pull/10057 | ||
| object CommandLineParser { | ||
| def tokenize(line: String): List[String] = scala.sys.process.Parser | ||
| .tokenize(line) | ||
| } | ||
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.
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 might be unlikely but in theory some other compiler plugin might define the same workaround. Have you maybe considered creating a dedicated proxy explicitly for rulesscala to decrease chances of name clash?
I had this issue recently when starting work on dependency analyzer plugin port to Scala 3. I've defined it there as following:
For Scala 2.13.10+
For other versions:
Then I've redefined
object TestUtilto extend this trait and used a proxy method instead of depending on compiler internalsThere 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.
Oh, this is better. I haven't actually done much Scala in a while, so this approach didn't occur to me, but it's definitely better than monkeypatching
scala.tools.cmd.I didn't see your original code in the existing code base, so I literally copied and pasted it into a new commit (crediting you, of course).
If this should live somewhere else, or you're about to check it in somewhere else (a quick
find | xargs grepdidn't turn it up), let me know.