Closed
Description
Compiler version
MWE based on 3.5.1
.
Notes
- We also managed to reproduce it on
3.6.2
. - The issue also seems unrelated to the build plugin of choice as it appears with both
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:
src/main/scala
└── org
└── example
├── App.scala
├── NumUtils.scala
├── greeting
│ └── Greeting.scala
└── macros
└── Macros.scala
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
, and NumUtils.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
,
To make sure that macros are the cause of the issue, simply make the
decorate
macro into a regular method:def decorate(s: String): String = s">>> $s <<<"and re-run tests and report generation. Coverage is now correctly computed.