Skip to content

Commit ad591bf

Browse files
committed
Updated inner docs
1 parent e3058ed commit ad591bf

File tree

1 file changed

+8
-6
lines changed
  • scalac-scoverage-plugin/src/main/scala/scoverage

1 file changed

+8
-6
lines changed

scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ class ScoverageInstrumentationComponent(val global: Global)
138138

139139
override def transform(tree: Tree) = process(tree)
140140

141-
def transformIf(tree: Tree) = {
142-
instrument(process(tree), true)
143-
}
144-
145141
def transformStatements(trees: List[Tree]): List[Tree] = trees.map(process)
146142

147143
def transformCases(cases: List[CaseDef]): List[CaseDef] = {
@@ -260,7 +256,8 @@ class ScoverageInstrumentationComponent(val global: Global)
260256

261257
/**
262258
* When an apply has no parameters, or is an application of purely literals or idents
263-
* then we can simply instrument the outer call.
259+
* then we can simply instrument the outer call. Ie, we can treat it all as one single statement
260+
* for the purposes of code coverage.
264261
* This will include calls to case apply.
265262
*/
266263
case a: GenericApply if allConstArgs(a.args) => instrument(a)
@@ -402,8 +399,12 @@ class ScoverageInstrumentationComponent(val global: Global)
402399

403400
case _: Ident => tree
404401

402+
// the If statement itself doesn't need to be instrumented, because instrumenting the condition is
403+
// enough to determine if the If statement was executed.
404+
// The two procedures (then and else) are instrumented seperately to determine if we entered
405+
// both branches.
405406
case i: If =>
406-
treeCopy.If(i, process(i.cond), transformIf(i.thenp), transformIf(i.elsep))
407+
treeCopy.If(i, process(i.cond), instrument(process(i.thenp), true), instrument(process(i.elsep), true))
407408

408409
case _: Import => tree
409410

@@ -477,6 +478,7 @@ class ScoverageInstrumentationComponent(val global: Global)
477478
// This AST node corresponds to the following Scala code: `return` expr
478479
case r: Return =>
479480
treeCopy.Return(r, transform(r.expr))
481+
480482
/** pattern match with syntax `Select(qual, name)`.
481483
* This AST node corresponds to the following Scala code:
482484
*

0 commit comments

Comments
 (0)