-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Move to nowarn instead of silencer #29932
Conversation
Side note: |
Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK ΤO ΤESΤ' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged. For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask! |
OK TO TEST |
project/AkkaDisciplinePlugin.scala
Outdated
"-P:silencer:globalFilters=The outer reference in this type test cannot be checked at run time", | ||
// Because we show some things that are deprecated in | ||
// 2.13 but don't have a replacement that was in 2.12: | ||
"-P:silencer:globalFilters=deprecated \\(since 2.13.0\\)")) |
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 seems Scala 2.13 doesn't like these settings - are there equivalent settings to configure 'nowarn'?
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 will fix it
Test PASSed. |
project/AkkaDisciplinePlugin.scala
Outdated
("com.github.ghik" %% "silencer-lib" % silencerVersion % Provided).cross(CrossVersion.patch)) | ||
Seq(libraryDependencies ++= (if (autoScalaLibrary.value) libs else Nil)) | ||
case _ => | ||
Seq(scalacOptions ++= Seq("-nowarn", "-Wconf:any:e")) |
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 have tried a bunch of patterns, but I have troubles and I might be falling into bugs.
E.g.
With this configuration: sbt -Dakka.build.scalaVersion=2.13 akka-actor/test:compile
result in 12 errors in akka-actors
all in:
@nowarn annotation does not suppress any warnings
The full scalacConfiguration is:
akka > show akka-actor/test:scalacOptions
[info] * -nowarn
[info] * -Wconf:any:e
[info] * -Xfatal-warnings
[info] * -Ywarn-extra-implicit
[info] * -Ywarn-unused:_
[info] * -Xlint
[info] * -deprecation
[info] * -encoding
[info] * UTF-8
[info] * -feature
[info] * -unchecked
[info] * -language:higherKinds
[info] * -target:jvm-1.8
It would be nice to get help from someone like @lrytz 🙏
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 compiler treats -Wconf
before -nowarn
. Using both -nowarn -Wconf:any:e
first promotes all warnings to be errors, so the messages are issued using reporter.error
, and -nowarn
has no effect anymore as it's checked in reporter.warning
.
@nowarn annotation does not suppress any warnings
is a warning enabled by -Xlint
, it means that a @nowarn
annotation is redundant, i.e., doesn't silence anything. It is reported as an error here because of -Wconf:any:e
.
Does that help..?
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.
Indeed, thanks a lot @lrytz I found my way out!
1437da6
https://github.com/akka/akka/pull/29932/checks?check_run_id=1669212181
Test PASSed. |
Test PASSed. |
|
||
// TODO: remove this when upgrading to Scala 2.12.13 | ||
// https://github.com/scala/scala/pull/9248 | ||
package scala.annotation |
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.
will this work with OSGi? I think it doesn't allow source in other packages than the root package of the module.
Eventually we will remove the OSGi support #28304 but we are not there yet.
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.
How can we test?
I was working under the assumption that, if the tests are passing, I'm not breaking anything.
That said, I'm not sure how can OSGi detect this, at best of my understanding:
- Akka depends on Scala and scala library should be on the classpath
- I'm not aware of a way to distinguish from which
jar
a specific class is coming from given a classpath @nowarn
is an annotation and should not spill to runtime
Am I making any wrong assumptions @patriknw ? I'm certainly not an OSGi expert ...
Bumped Scala 2.12 to |
Test FAILed. |
Test FAILed. |
Test FAILed. |
Test PASSed. |
@@ -63,17 +63,39 @@ object AkkaDisciplinePlugin extends AutoPlugin { | |||
"akka-stream-tests-tck", | |||
"akka-testkit") | |||
|
|||
lazy val silencerSettings = { |
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.
This is the relevant diff for reviewers.
Ready for a final review. |
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.
neat!
project/Dependencies.scala
Outdated
@@ -37,19 +37,21 @@ object Dependencies { | |||
val scalaTestVersion = "3.1.4" | |||
val scalaCheckVersion = "1.15.1" | |||
|
|||
def getScalaVersion() = { |
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.
def getScalaVersion() = { | |
def getScalaVersion() = { |
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 formatting is done by scalafmtSbt
, should I change it?
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.
are you sure? sbt scalafmtSbt
seems to change it for me as well
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'll re-run it so 👍
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.
scalafmt
was breaking, fixed, and re-formatted
project/Dependencies.scala
Outdated
@@ -37,19 +37,21 @@ object Dependencies { | |||
val scalaTestVersion = "3.1.4" | |||
val scalaCheckVersion = "1.15.1" | |||
|
|||
def getScalaVersion() = { | |||
// don't allow full override to keep compatible with the version of silencer |
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 guess this comment doesn't apply anymore as we don't use the silencer anymore?
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.
Good catch! This is an interesting subject, in the Scala 3 PR I'm heavily relying on this method, even if it looks like is not needed anymore, can I just remove the comment for now?
// don't allow full override to keep compatible with the version of silencer | ||
// don't mandate patch not specified to allow builds to migrate | ||
System.getProperty("akka.build.scalaVersion", "default") match { | ||
case twoThirteen if twoThirteen.startsWith("2.13") => scala213Version |
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.
(a bit weird but it was already like this so 👍 :) )
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 can include any encoding you prefer, I found it weird 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.
I suspect we still have jenkins jobs that pass 2.13.x
as akka.build.scalaVersion
, and we wanted to fix those before changing the startsWith
match to an exact match. Might be best to cover in another PR?
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.
deal 👍
Test PASSed. |
Superseded by #29956, I assume |
Follow up from:
#29929 (comment) (#29929)
Apart from the temporary workaround for Scala 2.12 I just validate that we can use the same approach for Scala 3.
Thanks, @ghik and @raboof