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

Add origin filter to WConf, DeprecationWarning #21404

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

som-snytt
Copy link
Contributor

The origin parameter to deprecationWarning is optional; the parameter to DeprecationWarning is not.

The origin of a deprecation is simply the deprecated symbol. The full name is matched by the regex specified by -Wconf.

The other important use case is the origin of an unused element, in particular, the selector which causes an "unused import" warning. That use case will be supported in a follow-up PR, and should work as in Scala 2.

Fixes #17538

@som-snytt som-snytt requested a review from lrytz August 20, 2024 20:18
@som-snytt som-snytt marked this pull request as ready for review August 20, 2024 22:20
@lrytz
Copy link
Member

lrytz commented Aug 23, 2024

We should add documentation here https://github.com/scala/scala3/blob/3.5.0/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala#L251

(After running sbt:scala3> buildQuick, why does bin/scalaQ -Wconf:help only show "-Wconf Configure compiler warnings." and nothing else...?)

Also here https://github.com/scala/scala3/blob/3.5.0/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala#L227

Looks good otherwise!

@som-snytt
Copy link
Contributor Author

Also the summary counts 4

there were 4 deprecation warnings; re-run with -deprecation for details
1 warning found

but under -deprecation

➜  dotty git:(issue/17538-wconf-origin) ✗ ~/projects/dotty/bin/scalacQ -d /tmp/sandbox -deprecation tests/warn/deprecated-origin.scala
-- Deprecation Warning: tests/warn/deprecated-origin.scala:12:18 ---------------
12 |  class D extends C // nowarn - C$ pattern avoids matching Crude
   |                  ^
   |                 class C in package p is deprecated since 1.0: Old style
-- Deprecation Warning: tests/warn/deprecated-origin.scala:13:20 ---------------
13 |  class Oil extends Crude // warn
   |                    ^^^^^
   |             class Crude in package p is deprecated since 1.0: Bad style
2 warnings found

@som-snytt
Copy link
Contributor Author

som-snytt commented Aug 24, 2024

It has taken me more than a few minutes on -Wconf:help, which works on 3.5.0. (This week I upgraded WSL to Ubuntu 24, so among my updated mechanisms is cs, which gave me 3.5.0.) Obviously, it's unpleasant that there is no test; there are a couple of major changes this year. This is what switched from using description to availableBlahBlah (which is shortDescription) f6345c6

➜  dotty git:(issue/17538-wconf-origin) ✗ scalac -version
Scala compiler version 3.5.0 -- Copyright 2002-2024, LAMP/EPFL
➜  dotty git:(issue/17538-wconf-origin) ✗ scalac -Wconf:help
Configure compiler warnings.
Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
multiple <filters> are combined with &, i.e., <filter>&...&<filter>

<filter>
  - Any message: any

  - Message categories: cat=deprecation, cat=feature, cat=unchecked

@som-snytt som-snytt force-pushed the issue/17538-wconf-origin branch from 77d194f to 929e7eb Compare August 24, 2024 21:41
Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

👍 looks good!

@lrytz lrytz merged commit 1604e77 into scala:main Aug 26, 2024
28 checks passed
@som-snytt
Copy link
Contributor Author

I didn't add a -Wconf:help test (the output doesn't show up under vulpix) and didn't look at the warning count issue.

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.

-Wconf and @nowarn do not support origin filter
3 participants