Skip to content

Commit 621f237

Browse files
committed
Added further clause to checking for for-loop
1 parent 8652ea2 commit 621f237

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/scala/scoverage/plugin.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ class ScoverageInstrumentationComponent(val global: Global)
437437

438438
// pattern match clauses will be instrumented per case
439439
case m@Match(clause: Tree, cases: List[CaseDef]) =>
440-
if (m.selector.tpe.annotations.mkString == "unchecked")
440+
// we can be fairly sure this was generated as part of a for loop
441+
if (m.selector.toString().contains("check$")
442+
&& m.selector.tpe.annotations.mkString == "unchecked"
443+
&& m.cases.last.toString == "case _ => false") // todo check these assumptions for 2.11
441444
treeCopy.Match(tree, instrument(clause), transformCases(cases.dropRight(1)) ++ cases.takeRight(1))
442445
else
443446
treeCopy.Match(tree, instrument(clause), transformCases(cases))

0 commit comments

Comments
 (0)