scala-cli
scala-cli copied to clipboard
Missing diagnostics from macros
Version(s) 1.0.5
Describe the bug It seems that some of the diagnostics sent from macros compiled in Bloop are missing in the Scala CLI output, but they are present in the IDE output, which means at some point they were also in Scala CLI
To Reproduce
// Main.scala
//> using scala 2.13.12
//> using dep org.scala-lang:scala-reflect:2.13.12
package example
import scala.reflect.macros.blackbox
import scala.language.experimental.macros
object Scala2Example {
def macroMethod[A](a: A): String =
macro Scala2Example.macroMethodImpl[A]
def macroMethodImpl[A: c.WeakTypeTag](
c: blackbox.Context
)(a: c.Expr[A]): c.Expr[String] = {
import c.universe._
val output = s"""${show(a.tree)}
|${showCode(a.tree)}
|${showRaw(a.tree)}
|${weakTypeTag[A]}
|${weakTypeOf[A]}
|${showRaw(weakTypeOf[A])}""".stripMargin
c.echo(c.enclosingPosition, output)
c.warning(c.enclosingPosition, "example error message")
c.abort(c.enclosingPosition, "example error message")
}
}
// Test.test.scala
//> using test.dep org.scalameta::munit::1.0.0-M10
package example
class Tests extends munit.FunSuite {
test("macro works OK") {
Scala2Example.macroMethod(1 -> "test")
}
}
This is printing:
Compiling project (test, Scala 2.13.12, JVM (17))
[error] ./Test.test.scala:7:5
[error] example error message
[error] Scala2Example.macroMethod(1 -> "test")
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error compiling project (test, Scala 2.13.12, JVM (17))
Compilation failed
Expected behaviour It should also print (I think the severity is different at hint level)
scala.Predef.ArrowAssoc[Int](1).->[String](\"test\")\nscala.Predef.ArrowAssoc[Int](1).->[String](\"test\")\nApply(TypeApply(Select(Apply(TypeApply(Select(Select(Ident(scala), scala.Predef), TermName(\"ArrowAssoc\")), List(TypeTree())), List(Literal(Constant(1)))), TermName(\"$minus$greater\")), List(TypeTree())), List(Literal(Constant(\"test\"))))\nWeakTypeTag[(Int, String)]\n(Int, String)\nTypeRef(ThisType(scala), scala.Tuple2, List(TypeRef(ThisType(scala), scala.Int, List()), TypeRef(ThisType(java.lang), java.lang.String, List())))
This is a duplicate of #357, I think.
That is different, since the stacktraces are not being sent at all while these are normal diagnostics. They are printed by Metals, but not printed by scala-cli, which should be quick to fix.
I see.
Note that compiler plugins are affected as well. I am debugging a Scala 3 compiler plugin, and the debugging output from the plugin vanishes. --server=false makes the output appear as expected.