Skip to content

Commit a05592c

Browse files
committed
Used MacroExpansion for better macro detection
1 parent a9aaf62 commit a05592c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/scala/scoverage/plugin.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ScoverageInstrumentationComponent(val global: Global)
107107
override def newPhase(prev: scala.tools.nsc.Phase): Phase = new Phase(prev) {
108108

109109
override def run(): Unit = {
110-
println("[scoverage]: Cleaning datadir")
110+
println(s"[scoverage]: Cleaning datadir [${options.dataDir}]")
111111
IOUtils.clean(options.dataDir)
112112

113113
println("[scoverage]: Begin instrumentation phase")
@@ -294,7 +294,11 @@ class ScoverageInstrumentationComponent(val global: Global)
294294
tree match {
295295

296296
// ignore synthetic trees that contain non-syths. Probably macros. Either way breaks due to range validation
297-
case t if isSynthetic(t) && containsNonSynthetic(t) && !t.pos.isDefined => super.transform(t)
297+
//case t if isSynthetic(t) && containsNonSynthetic(t) && !t.pos.isDefined =>
298+
// super.transform(t)
299+
300+
// ignore macro expanded code
301+
case tree if tree.attachments.all.toString().contains("MacroExpansionAttachment") => tree
298302

299303
/**
300304
* Object creation from new.

src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class PluginCoverageTest
9494
| }
9595
|} """.stripMargin)
9696
assert(!reporter.hasErrors)
97-
assertNoCoverage
97+
assertNoCoverage()
9898
}
9999

100100
// https://github.com/skinny-framework/skinny-framework/issues/97
@@ -109,6 +109,6 @@ class PluginCoverageTest
109109
|} """.stripMargin)
110110
assert(!reporter.hasErrors)
111111
assert(!reporter.hasWarnings)
112-
assertNoCoverage
112+
assertNoCoverage()
113113
}
114114
}

0 commit comments

Comments
 (0)