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

tools.reflect.FrontEnd misses Infos when typechecking trees with NoPosition #9868

Open
scabug opened this issue Jul 24, 2016 · 1 comment
Open

Comments

@scabug
Copy link

scabug commented Jul 24, 2016

When using ToolBox to typecheck a tree, e.g. created with quasiquotes, the reporting FrontEnd can miss some of the reported infos.

tools.reflect.FrontEnd uses a LinkedHashSet to store reported infos. The case class Info contains the position, a message and a severity. For quasiquotes, the position is always NoPosition and, thus, infos with the same severity and message are only stored once in the set.

The following code compiles a tree which should report two warnings, but it only gives me one:

    import scala.reflect.runtime.currentMirror
    import scala.reflect.runtime.universe._
    import scala.tools.reflect.{FrontEnd, ToolBox}

    val reporter = new FrontEnd {
      override def display(info: Info) {}
      override def interactive() {}
    }

    val toolbox = currentMirror.mkToolBox(reporter)
    val tree = q"object A { def foo[T](t: T) = 1.isInstanceOf[T]; def bar[T](t: T) = 1.isInstanceOf[T] }"
    val typedTree = toolbox.typecheck(tree)
    println(reporter.infos) // Set(Info(NoPosition,abstract type T is unchecked since it is eliminated by erasure,WARNING))

I would have expected to get a list of two warnings.

@scabug
Copy link
Author

scabug commented Jul 24, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9868?orig=1
Reporter: Johannes Karoff (cornerman)
Affected Versions: 2.11.8

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

4 participants