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

Can't use -Xfatal-warnings when anything is deprecated #8410

Closed
scabug opened this issue Mar 13, 2014 · 10 comments
Closed

Can't use -Xfatal-warnings when anything is deprecated #8410

scabug opened this issue Mar 13, 2014 · 10 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 13, 2014

I really want to make value discarding warnings fatal as I have hit many bugs in production because of it. Sadly, we have a few things we're using deprecated (I do not care about those, for the moment) - so when I run:

$ ./qbin/scala -Xfatal-warnings
Welcome to Scala version 2.11.0-20140312-105634-9c38e86a55 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> @deprecated("Bad", "1.0") def addOne(x: Int) = { x + 1 }
addOne: (x: Int)Int

scala> addOne(2)
error: there were 1 deprecation warning(s); re-run with -deprecation for details

I have not turned on the -deprecation flag, so I do not expect an error to occur. Can we make this be a warning until that flag is turned on?

@scabug
Copy link
Author

scabug commented Mar 13, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8410?orig=1
Reporter: @puffnfresh
Affected Versions: 2.11.0-RC1

@scabug
Copy link
Author

scabug commented Mar 13, 2014

@retronym said:
We're working on a configurable warning escalation / demotion facility but it won't be here until 2.11.1.

For now, I'd suggest to run without fatal warnings and post-process the compiler output in a build tool.

@scabug
Copy link
Author

scabug commented Mar 13, 2014

@puffnfresh said:
@retronym as you know, I'm really interested in configurable warnings. Is there anything available to see what the plan is?

@scabug
Copy link
Author

scabug commented Mar 13, 2014

@retronym said:
Adriaan is prototyping something here: https://github.com/adriaanm/scala/tree/report-filter

Another (SBT specific) angle would be to add a hook into:

https://github.com/sbt/sbt/blob/0.13/compile/interface/src/main/scala/xsbt/DelegatingReporter.scala

to filter to your hearts content.

@scabug
Copy link
Author

scabug commented Mar 13, 2014

@puffnfresh said:
I've added this extremely awful task to SBT:

def fatalWarningsTask = TaskKey[Unit]("fatalWarnings") <<= Def.task {
  fatalWarningsTaskImpl(streams.value, (compile in Compile).value)
}

def fatalWarningsTaskImpl(s: TaskStreams, a: sbt.inc.Analysis) {
  def logProblem(l: (=> String) => Unit, f: File, p: xsbti.Problem) = {
    l(f.toString + ":" + p.position.line.fold("")(_ + ":") + " " + p.message)
    l(p.position.lineContent)
    l("")
  }

  var failed = 0
  a.infos.allInfos.foreach { case (k, i) =>
    i.reportedProblems foreach { p =>
      val deprecation = p.message.contains("is deprecated")

      if(!deprecation)
        failed = failed + 1

      logProblem(if(deprecation) s.log.warn else s.log.error, k, p)
    }
  }

  if(failed > 0)
    error("Fatal warnings")
}

A total mess.

@scabug
Copy link
Author

scabug commented Mar 14, 2014

@som-snytt said (edited on Sep 1, 2014 12:12:14 PM UTC):
The traditional advice on deprecation warnings is to pipe it through a deprecated something that doesn't warn.

Retronym has suggested deprecating a trait, implemented by its companion, and use the module method.

I have suggested deprecating a local function that forwards the call, to the same effect.

Edit: deprecated locals loophole was closed in 2.11.0-M8.

@scabug
Copy link
Author

scabug commented Mar 18, 2014

@SethTisue said:
#7529 is very similar, just replacing -deprecation with -Yinline-warnings.

@scabug
Copy link
Author

scabug commented Sep 1, 2014

@som-snytt said (edited on Mar 4, 2017 1:19:32 AM UTC):
This PR respects explicit settings (which were new this year):

-deprecation:false -Yinline-warnings:false

scala/scala#3955

@scabug scabug closed this as completed Sep 3, 2014
@scabug
Copy link
Author

scabug commented Mar 3, 2017

@adriaanm said:
With scala/scala#4544, a cleaner solution is within reach, btw.

@SethTisue
Copy link
Member

https://github.com/ghik/silencer is useful here

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

No branches or pull requests

3 participants