-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support src filter in -WConf (Closes #17635) #18783
Conversation
added the f- word to the comment, which links the ticket; I hope that was intended. |
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 @povder!
case None => false | ||
|
||
case Any, Deprecated, Feature, Unchecked, None | ||
case MessagePattern(pattern: Regex) | ||
case MessageID(errorId: ErrorMessageID) | ||
case SourcePattern(pattern: Regex) |
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.
Old code had a cache, shouldn't that be provided too?
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.
cache added
ad9fd2a
to
dd2e03b
Compare
|
||
enum MessageFilter: | ||
|
||
private val sourcePatternCache = mutable.Map.empty[SourceFile, Boolean] |
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.
The cache should probably be cleared on each compiler run (dotc.Compiler.newRun
). What utilities does dotty have to manage caches?
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.
There is the PerRun
in Definitions
.
Or we could make it a Map of (pattern, SourceFile) -> Boolean. I think there is no state to influence the check if a source file matches a pattern.
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.
Multiple compiler instances running at the same time might concurrently try to access and update this cache, so if this really needs to be a global map (seems like it should be tied to the Context instead?) it needs to be a ConcurrentHashMap (I'm surprised this wasn't caught by https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/transform/CheckReentrant.scala)
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.
Not knowing how this works exactly from the concurrency perspective I attempted porting over Scala2 implementation which was a plain mutable map. Given concerns about the concurrency though, would it be acceptable to not do caching in this PR? We could always make an optimization later without holding back the feature
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.
TBH, it was me who mentioned the cache. I can withdraw my comment
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.
cache removed
@@ -266,6 +269,7 @@ private sealed trait WarningSettings: | |||
|Examples: | |||
| - change every warning into an error: -Wconf:any:error | |||
| - silence deprecations: -Wconf:cat=deprecation:s | |||
| - silence warnings in src_managed directory: -Wconf:src=src_managed/.* |
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.
Shouldn't this example end with :s
or :silent
?
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.
@@ -96,5 +101,52 @@ class ScalaSettingsTests: | |||
assertEquals(Action.Silent, sut.action(depr)) | |||
|
|||
|
|||
private def wconfSrcFilterTest(argsStr: String, source: util.SourceFile, expectedAction: reporting.Action): Unit = |
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.
Please add a test with malformed regex and add an assertion on the error.
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.
Add also a test that mixes it with different wconf flags
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.
Please add a test with malformed regex and add an assertion on the error.
Added
d65e8f8#diff-f4b356d10a0ec15d5030bed4c51b0fc839753cc43c5854475ed9701e6bc5148bR170
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.
Add also a test that mixes it with different wconf flags
Added
d65e8f8#diff-f4b356d10a0ec15d5030bed4c51b0fc839753cc43c5854475ed9701e6bc5148bR187
0cb7d2e
to
4f40ecd
Compare
) | ||
) | ||
|
||
@Test def `WConf src filter can be mixed with other filters with rightmost taking precedence`: Unit = |
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.
Hmm, in Scala 2 the leftmost takes precedence. Also -Wconf:help
(on Scala 3) says otherwise.
So this is a bug that should be fixed. I think a separate PR is better, so I filed #19885.
It's really awesome to see this PR and all the efforts done by @povder ! What is holding this up at the moment? Is it the "change requested" review from @szymon-rd from December? It would be amazing to get this feature back in Scala3 |
@szymon-rd @Kordyjan I've addressed the comments quite a while ago, could I have another review or possibly this could be merged now? |
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.
LGTM now - But I am no longer in the team maintaining this repo, so probably better to tag someone else to merge it to main @Kordyjan
edit: Oh, I see you already tagged him
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.
Looks great to me!
Would it be possible to backport this to 3.3.x? |
Conflict between scala#18783 and scala#19766
I think it will be backported. We are trying to have all reporting and lining improvements on LTS. |
Awesome! Should I open a backport PR? Or will you do this? |
I opened a backport PR: |
Backports #18783 to the LTS branch. PR submitted by the release tooling. [skip ci]
Fixes #18782