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

2.12.4 regression. "-Ywarn-unused" reports unused implicit param, however it's used within macro expansion #10579

Closed
mosyp opened this issue Oct 31, 2017 · 4 comments

Comments

@mosyp
Copy link

mosyp commented Oct 31, 2017

Given scalacOptions ++= Seq("-Xfatal-warnings", "-Ywarn-unused") and simple macro:

object TestMacro {
  def runAsync[T](x: T): Future[T] = macro runAsyncMacro[T]
  def runAsyncMacro[T](c: blackbox.Context)(x: c.Tree)(implicit t: c.universe.WeakTypeTag[T]): c.Tree = {
    import c.universe._
    c.typecheck(q"""scala.concurrent.Future[$t]($x)""")
  }
}

Following code compiles in 2.12.3:

object TestRun {
  def test(implicit ec: ExecutionContext): Unit = {
    TestMacro.runAsync(123)
  }
}

But fails in 2.12.4:

[error] TestRun.scala:4: parameter value ec in method test is never used
[error]   def test(implicit ec: ExecutionContext): Unit = {
@SethTisue
Copy link
Member

caused by scala/scala#6096, I presume. so this is working as intended, but also there's room for further improvement, e.g. by making it possible for a macro author to control which behavior is intended. @som-snytt is there a ticket of record on that?

@som-snytt
Copy link

Duplicates #10571

use -Ywarn-macros:after to lint after expansion.

@mxl
Copy link

mxl commented Oct 31, 2017

@som-snytt Thanks! Where can I read more about these scalac options?

@som-snytt
Copy link

@mxl That's a good question. I haven't been able to turn on the optimizer for a while now.

scalac -help -X -Y, -opt:help. The release notes also include handy links to bugs and PRs.

I just realized I forgot to update my shell alias to scala -Dscala.repl.welcome=banner.

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

4 participants