File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
scalac-scoverage-plugin/src Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ class ScoverageInstrumentationComponent(val global: Global)
155
155
def instrument (tree : Tree , branch : Boolean = false ): Tree = {
156
156
safeSource(tree) match {
157
157
case None =>
158
- println(s " [warn] [scoverage] Could not instrument [ ${tree.getClass.getSimpleName}/ ${tree.symbol}]. No pos. " )
158
+ println(s " [warn] Could not instrument [ ${tree.getClass.getSimpleName}/ ${tree.symbol}]. No pos. " )
159
159
tree
160
160
case Some (source) =>
161
161
if (tree.pos.isDefined && ! isStatementIncluded(tree.pos)) {
@@ -465,6 +465,8 @@ class ScoverageInstrumentationComponent(val global: Global)
465
465
* List(Literal(Constant(3))))
466
466
*
467
467
*/
468
+ case n : New => n
469
+
468
470
case s@ Select (n@ New (tpt), name) =>
469
471
instrument(treeCopy.Select (s, n, name))
470
472
Original file line number Diff line number Diff line change @@ -106,8 +106,9 @@ class PluginCoverageTest
106
106
107
107
test(" scoverage should correctly handle new that invokes nested statements" ) {
108
108
val compiler = ScoverageCompiler .default
109
- compiler.compileCodeSnippet( """ object A {
110
- | new String(if (System.currentTimeMillis > 1) "yes" else "no")
109
+ compiler.compileCodeSnippet( """
110
+ | object A {
111
+ | val value = new java.util.concurrent.CountDownLatch(if (System.currentTimeMillis > 1) 5 else 10)
111
112
| } """ .stripMargin)
112
113
assert(! compiler.reporter.hasErrors)
113
114
assert(! compiler.reporter.hasWarnings)
You can’t perform that action at this time.
0 commit comments