Macro info logging bug?

I’ve noticed that if I call, "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._, "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, 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.

Hi James,

It seems you cannot rely on a specific behavior with respect to that parameter. The doc says that messages may be suppressed, without specifying when they are or aren’t.

In particular, the ContextReporter ignores the parameter.

Cheers: Lukas

Thanks for the reply Lukas.

Regarding the ‘may’ in the documentation, you’re right it is ambiguous.

So it is expected behaviour that all internal logging of all macros is exposed to the end user during compilation? That’s not great behaviour in my opinion. Perhaps I can make this a feature request instead of a bug…

Maybe c.settings works for your use-case? See

@Irytz How does that help? Also this is not the only case where logging fails. It also failed in implicit macro:

Can’t believe it still doesn’t work after 4 years