Skip to content

Commit 9cf6357

Browse files
authored
Merge pull request #253 from scoverage/fix-compilation-warnings
Fix different compilation warnings
2 parents 417bbe2 + 88fc212 commit 9cf6357

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object CoverageAggregator {
2828
if (coverageFile.exists) {
2929
val subcoverage: Coverage = Serializer.deserialize(coverageFile)
3030
val measurementFiles: Array[File] = IOUtils.findMeasurementFiles(dataDir)
31-
val measurements = IOUtils.invoked(measurementFiles)
31+
val measurements = IOUtils.invoked(measurementFiles.toIndexedSeq)
3232
subcoverage.apply(measurements)
3333
subcoverage.statements foreach { stmt =>
3434
// need to ensure all the ids are unique otherwise the coverage object will have stmt collisions

scalac-scoverage-plugin/src/test/scala/scoverage/CoverageMetricsTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CoverageMetricsTest extends FreeSpec with Matchers {
2121
override def ignoredStatements: Iterable[Statement] = Seq()
2222
}
2323
metrics.branchCount shouldBe 0
24-
metrics.branchCoverage - 1 shouldBe < (0.0001)
24+
metrics.branchCoverage shouldBe 1.0 +- 0.0001
2525
}
2626

2727
"no branches with no invoked statements should have 0% branch coverage" in {

scalac-scoverage-plugin/src/test/scala/scoverage/LocationTest.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ class LocationTest extends FreeSpec with Matchers {
187187
compiler
188188
.compile(
189189
"package com.a; object A { def foo(b : B) : Unit = b.invoke }; trait B { def invoke : Unit }; class C { A.foo(new B { def invoke = () }) }")
190-
println()
191-
println(compiler.locations.result().mkString("\n"))
192190
val loc = compiler.locations.result().filter(_._1 == "Template").last._2
193191
loc.packageName shouldBe "com.a"
194192
loc.className shouldBe "C"

scalac-scoverage-plugin/src/test/scala/scoverage/MacroSupport.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import java.io.File
44

55
trait MacroSupport {
66

7+
val macroContextPackageName: String = if (ScoverageCompiler.ShortScalaVersion == "2.10") {
8+
"scala.reflect.macros"
9+
}
10+
else {
11+
"scala.reflect.macros.blackbox"
12+
}
13+
714
val macroSupportDeps = Seq(testClasses)
815

916
private def testClasses: File = new File(s"./scalac-scoverage-plugin/target/scala-${ScoverageCompiler.ShortScalaVersion}/test-classes")

scalac-scoverage-plugin/src/test/scala/scoverage/PluginASTSupportTest.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ class PluginASTSupportTest
8383

8484
test("scoverage component should ignore basic macros") {
8585
val compiler = ScoverageCompiler.default
86-
compiler.compileCodeSnippet( """
86+
compiler.compileCodeSnippet( s"""
8787
| object MyMacro {
8888
| import scala.language.experimental.macros
89-
| import scala.reflect.macros.Context
90-
| def test = macro testImpl
89+
| import ${macroContextPackageName}.Context
90+
| def test: Unit = macro testImpl
9191
| def testImpl(c: Context): c.Expr[Unit] = {
9292
| import c.universe._
9393
| reify {
@@ -100,12 +100,12 @@ class PluginASTSupportTest
100100

101101
test("scoverage component should ignore complex macros #11") {
102102
val compiler = ScoverageCompiler.default
103-
compiler.compileCodeSnippet( """ object ComplexMacro {
103+
compiler.compileCodeSnippet( s""" object ComplexMacro {
104104
|
105105
| import scala.language.experimental.macros
106-
| import scala.reflect.macros.Context
106+
| import ${macroContextPackageName}.Context
107107
|
108-
| def debug(params: Any*) = macro debugImpl
108+
| def debug(params: Any*): Unit = macro debugImpl
109109
|
110110
| def debugImpl(c: Context)(params: c.Expr[Any]*) = {
111111
| import c.universe._
@@ -114,7 +114,7 @@ class PluginASTSupportTest
114114
| case Literal(Constant(_)) => reify { print(param.splice) }
115115
| case _ => reify {
116116
| val variable = c.Expr[String](Literal(Constant(show(param.tree)))).splice
117-
| print(s"$variable = ${param.splice}")
117+
| print(s"$$variable = $${param.splice}")
118118
| }
119119
| }).tree
120120
| }

scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ class PluginCoverageTest
3535
}
3636
3737
object Macros {
38-
def poly[T] = macro Impl.poly[T]
38+
def poly[T]: String = macro Impl.poly[T]
3939
}"""
4040
else
41-
"""
41+
s"""
4242
import scala.language.experimental.macros
43-
import scala.reflect.macros.Context
43+
import scala.reflect.macros.blackbox.Context
4444
class Impl(val c: Context) {
4545
import c.universe._
46-
def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString)
46+
def poly[T: c.WeakTypeTag] = q"$${c.weakTypeOf[T].toString}"
4747
}
4848
object Macros {
49-
def poly[T] = macro Impl.poly[T]
49+
def poly[T]: String = macro Impl.poly[T]
5050
}"""
5151
compiler.compileCodeSnippet(code)
5252
assert(!compiler.reporter.hasErrors)
@@ -269,11 +269,11 @@ class PluginCoverageTest
269269

270270
test("plugin should not instrument local macro implementation") {
271271
val compiler = ScoverageCompiler.default
272-
compiler.compileCodeSnippet( """
272+
compiler.compileCodeSnippet( s"""
273273
| object MyMacro {
274274
| import scala.language.experimental.macros
275-
| import scala.reflect.macros.Context
276-
| def test = macro testImpl
275+
| import ${macroContextPackageName}.Context
276+
| def test: Unit = macro testImpl
277277
| def testImpl(c: Context): c.Expr[Unit] = {
278278
| import c.universe._
279279
| reify {

scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ object ScoverageCompiler {
2222
def settings: Settings = {
2323
val s = new scala.tools.nsc.Settings
2424
s.Xprint.value = List("all")
25+
s.deprecation.value = true
2526
s.Yrangepos.value = true
2627
s.Yposdebug.value = true
2728
s.classpath.value = classPath.mkString(File.pathSeparator)

0 commit comments

Comments
 (0)