Macros lead to wrong coverage reports #22247
Labels
area:coverage
Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html
area:metaprogramming:other
Issues tied to metaprogramming/macros not covered by the other labels.
itype:bug
Compiler version
MWE based on
3.5.1
.Notes
3.6.2
.sbt-scoverage
andgradle-scoverage
(reproducer uses the former).Minimized code
An MWE can be found here. The reproducer is minimal but requires interaction between multiple files.
Code overview
The code is organized as follows:
The key points are:
Greeting.scala
defines the logic to greet users (greet: Option[String] => String
);Macros.scala
defines a macro to decorate strings at compile time (decorate: String => String
);App.scala
greets an undefined user and decorates a string using the macro (println(decorate(greet(None)))
);NumUtils.scala
defines a simple functionisEven
, which is completely unrelated to the rest of the code.Output
The coverage report fails to include
Greeting.scala
,Macros.scala
, andNumUtils.scala
. Moreover, it shows 100%coverage for
App.scala
even though it should be 0% (main
method is never called in the tests).Expectation
We expect to get an equivalent report as if macros were converted to ordinary methods. As explained in the
README
,The text was updated successfully, but these errors were encountered: