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

Multivalued setting can be set multiply #9731

Merged
merged 6 commits into from
Sep 14, 2020
Merged

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Sep 5, 2020

Permit -language:foo -language:bar to mean -language:foo,bar,
and similarly for other settings which are multivalued (i.e.,
have a value which is a list). Such settings include -Xplugin
and -Xprint. There is no mechanism to distinguish phase names
from other string settings.

Learning again how to run a junit test is a big win.

Fixes #9719

Remove comment referring to ancient Scala 2 bug.

Adjust imports to read: imports relative to packaging,
then absolute dotty packages, then scala packages.
Permit `-language:foo -language:bar` to mean `-language:foo,bar`,
and similarly for other settings which are multivalued (i.e.,
have a value which is a list). Such settings include `-Xplugin`
and `-Xprint`. There is no mechanism to distinguish phase names
from other string settings.
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Thanks a lot @som-snytt 👍

LGTM, some minor comments.

@@ -17,7 +17,7 @@ import Diagnostic._
* - The reporter is not flushed and the message containers capture a
* `Context` (about 4MB)
*/
class StoreReporter(outer: Reporter) extends Reporter {
class StoreReporter(outer: Reporter = null) extends Reporter {
Copy link
Contributor

@liufengyun liufengyun Sep 14, 2020

Choose a reason for hiding this comment

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

I'd suggest remove this default value, as it is not common for outer to be null. Moreover, this creates more subtleties for the usage of outer inside StoreReporter. There is Reporter.NoReporter, which can be used where null is needed.

if Files.notExists(outputDir)
Files.createDirectory(outputDir)
val options = Array("-encoding", "-d", outputDir.toString, source.toString)
val reporter = Main.process(options, reporter = StoreReporter())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val reporter = Main.process(options, reporter = StoreReporter())
val reporter = Main.process(options, reporter = StoreReporter(Reporter.NoReporter))

val options = Array("-d", "not_here")
val reporter = Main.process(options)
val reporter = Main.process(options, reporter = StoreReporter())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val reporter = Main.process(options, reporter = StoreReporter())
val reporter = Main.process(options, reporter = StoreReporter(Reporter.NoReporter))

val value0 = value.asInstanceOf[List[String]]
val current = valueIn(sstate).asInstanceOf[List[String]]
val newly = current ++ value0.filterNot(current.contains)
(newly, value0.exists(current.contains))
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be simpler: newly.size <= current.size?

(newly, value0.exists(current.contains))
else
(value, changed)
val dangers = if twicely then warnings :+ s"Flag $name set repeatedly" else warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

This warning is not informative for multivalued settings, as it's OK to set them multiple times.

Copy link
Contributor Author

@som-snytt som-snytt Sep 14, 2020

Choose a reason for hiding this comment

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

Redundant -language:foo -language:foo or -Wconf:cat=deprecation:s -Wconf:cat=deprecation:s is probably unintended, although possibly harmless. Or, -Wconf:cat=deprecation:s -Wconf:msg='foo':e -Wconf:cat=deprecation:s may be ambiguous; or it may be intentional. I'll remove the filter completely instead of guessing. -language:dynamics,-dynamics enables, -language:_,-dynamics disables.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I wasn't clear. I don't mean to suppress the warning. I mean to improve the warning to say a specific value is set multiple times.

Warn but don't ignore redundant setting.

Prefer NoReporter to null default reporter.
val reporter = Main.process(options)
if Files.notExists(outputDir)
Files.createDirectory(outputDir)
val options = Array("-encoding", "-d", outputDir.toString, source.toString)
Copy link
Contributor

Choose a reason for hiding this comment

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

The argument is missing for -encoding. Or remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ticket is about the missing arg.

@liufengyun liufengyun merged commit bd05d37 into scala:master Sep 14, 2020
@som-snytt som-snytt deleted the issue/9719 branch September 14, 2020 16:00
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

Multiple language features in scalacOptions not recognized
4 participants