I’ve noticed that if I call c.info(pos, "message", force = false)
inside a macro, it prints out on compilation despite the force
parameter. The docs say that should mean the message is suppressed.
Here is some example code which does it:
import scala.reflect.macros.Context
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
object Macros {
def hello: Unit = macro helloImpl
def helloImpl(c: blackbox.Context): c.Expr[Unit] = {
import c.universe._
c.info(c.enclosingPosition, "Message!", force = false)
}
}
[INFO] <filepath> Message!
is always logged, with force = true
and force = false
.
Note this only happens on sbt compile - it does not happen in a repl.
I’ve tried digging through the source scala code to find out why it’s doing this, but without an IDE it’s not very navigable.
Could anyone more knowledgeable point me in the right direction? I know it calls info
in scala.tools.nsc.reporters.Reporter
, which then calls some implementation of info0
, but for the life of me I cannot find which one. I’ve tagged every implementation of info0
and none are called.