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

Wconf/nowarn do not work for compiler plugins #12258

Open
neko-kai opened this issue Dec 7, 2020 · 7 comments
Open

Wconf/nowarn do not work for compiler plugins #12258

neko-kai opened this issue Dec 7, 2020 · 7 comments

Comments

@neko-kai
Copy link

neko-kai commented Dec 7, 2020

reproduction steps

using Scala 2.13.4,

@scala.annotation.nowarn("msg=kind-projector")
object x extends App {
  class OptionT[F[_], A]
  def xa(f: OptionT[Option[?], Int]) = ()
}

https://scastie.scala-lang.org/epxMf0GETwKx2sOIp9rkKA

problem

This produces a warning

kind-projector ? placeholders are deprecated. Use * instead of ? for cross-compatibility with Scala 3

Despite nowarn annotation filtering it. The same applies to -Wconf:msg=kind-projector:silent

expectation

Expected compiler-plugin generated warnings to also be ignored

@sjrd
Copy link
Member

sjrd commented Dec 7, 2020

That's because the compiler plugins emit warnings in the old way, which the warning configuration system cannot see/tweak. Compiler plugins need to be adapted to call the overload of warning that takes a Category and a site. For example:
https://github.com/scala-js/scala-js/blob/950fcda1e480d54b50e75f4cce5bd4135cb58a53/compiler/src/main/scala/org/scalajs/nscplugin/GenJSCode.scala#L401-L407

To be able to write this in a source-compatible way with all versions of the compiler API, they can use the following hacks:
https://github.com/scala-js/scala-js/blob/950fcda1e480d54b50e75f4cce5bd4135cb58a53/compiler/src/main/scala/org/scalajs/nscplugin/CompatComponent.scala#L43-L55
https://github.com/scala-js/scala-js/blob/950fcda1e480d54b50e75f4cce5bd4135cb58a53/compiler/src/main/scala/org/scalajs/nscplugin/CompatComponent.scala#L114-L132

@neko-kai
Copy link
Author

neko-kai commented Dec 7, 2020

@sjrd This could be supported on the backend, too though, since msg= filter does not require category.

@sjrd
Copy link
Member

sjrd commented Dec 7, 2020

It doesn't require a category, but it requires a site (at least for @nowarn, not for the compiler flag -Wconf).

@neko-kai
Copy link
Author

neko-kai commented Dec 7, 2020

Makes sense, -Wconf ought to work in theory but fails to catch this case too (https://scastie.scala-lang.org/wC42UzZ3T2i0l0sq19ubqw)

@NthPortal
Copy link

this seems like something for which @som-snytt might have insight

@preveen-stack
Copy link

Is this issue still valid?

@SethTisue
Copy link
Member

@preveen-stack it would be helpful if you attempted to verify that yourself. Has kind-projector been modified to follow this advice?:

Compiler plugins need to be adapted to call the overload of warning that takes a Category and a site

If it has been, are there still warnings coming from the plug-in that can't be suppressed, as @neko-kai's comment above seems to indicate? Are you able to reproduce that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants