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

TypeTag implicit incorrectly marked as unused #12356

Closed
koterpillar opened this issue Mar 2, 2021 · 3 comments
Closed

TypeTag implicit incorrectly marked as unused #12356

koterpillar opened this issue Mar 2, 2021 · 3 comments

Comments

@koterpillar
Copy link

reproduction steps

using Scala 2.13.5 with -Wunused:

import scala.reflect.runtime.universe._

object foo {
  case class Wrap[A](value: A)

  def withTag[A: TypeTag]: Unit = ()

  // new in 2.13.5, incorrect:
  // warning: parameter value evidence$2 in method withTagWrap1 is never used
  def withTagWrap1[A: TypeTag]: Unit = withTag[Wrap[A]]

  // this is expected:
  // error: No TypeTag available for blah.foo.Wrap[A]
  def withTagWrap2[A]: Unit = withTag[Wrap[A]]
}

problem

The TypeTag[A] context bound in withTagWrap1 is used (to derive TypeTag[Wrap[A]]) and should not be reported as unused.

The same code works in Scala 2.13.4.

Possibly related to scala/scala#9346.

@som-snytt
Copy link

It won't warn with -Wmacros:after. Use -Xprint:typer to see the expansion.

Use -Vmacro-lite to see

performing macro expansion scala.reflect.api.`package`.materializeTypeTag[foo.Wrap[A]]

It's possible to disable -Wunused:-synthetics or use -Xlint:unused for less fuss, or use -Wconf to limit warnings.

Thanks for the report. Probably at this point, the interaction with macros will not be further improved.

@NthPortal
Copy link

@som-snytt why would it have to do with -Wmacros:after? there are no macros here

@Jasper-M
Copy link
Member

Jasper-M commented Mar 2, 2021

@NthPortal There's an implicit TypeTag[A] in scope, but a (intrinsic) macro is required to generate the TypeTag[Wrap[A]].

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