From 1154886a3e1a4f8454e57a9b74897f26d027a719 Mon Sep 17 00:00:00 2001 From: Grzegorz Slowikowski Date: Mon, 14 Aug 2017 13:23:48 +0200 Subject: [PATCH] Fix problems found in original fix to #193 Changes: - revert two changes in `plugin.scala` file (see comment https://github.com/scoverage/scalac-scoverage-plugin/issues/193#issuecomment-296429944) - upgrade Scala version from 2.12.0 to 2.12.1 --- .travis.yml | 2 +- build.sbt | 4 ++-- scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala | 4 +--- .../src/test/scala/scoverage/PluginCoverageTest.scala | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea23abf4..1b4f3eeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: - jdk: oraclejdk7 scala: 2.11.8 - jdk: oraclejdk8 - scala: 2.12.0 + scala: 2.12.1 before_cache: - find "$HOME/.sbt/" -name '*.lock' -print0 | xargs -0 rm diff --git a/build.sbt b/build.sbt index 067a09be..6a8d90fd 100644 --- a/build.sbt +++ b/build.sbt @@ -12,8 +12,8 @@ val ScalatestVersion = "3.0.0" val appSettings = Seq( organization := Org, - scalaVersion := "2.12.0", - crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0"), + scalaVersion := "2.12.1", + crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1"), fork in Test := false, publishMavenStyle := true, publishArtifact in Test := false, diff --git a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala index 7ee89899..b8416c72 100644 --- a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala +++ b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala @@ -581,9 +581,6 @@ class ScoverageInstrumentationComponent(val global: Global, extraAfterPhase: Opt case _: TypeTree => super.transform(tree) - // if the rhs of a val is a literal we can just leave it - case v: ValDef if v.rhs.isInstanceOf[Literal] => tree - /** * We can ignore lazy val defs as they are implemented by a generated defdef */ @@ -602,6 +599,7 @@ class ScoverageInstrumentationComponent(val global: Global, extraAfterPhase: Opt // we need to remove the final mod so that we keep the code in order to check its invoked case v: ValDef if v.mods.isFinal => + updateLocation(v) treeCopy.ValDef(v, v.mods.&~(ModifierFlags.FINAL), v.name, v.tpt, process(v.rhs)) /** diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala index bf4adbcd..20c9b895 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala @@ -23,7 +23,7 @@ class PluginCoverageTest // we expect: // instrumenting the default-param which becomes a method call invocation // the method makeGreeting is entered. - compiler.assertNMeasuredStatements(1) + compiler.assertNMeasuredStatements(2) } test("scoverage should skip macros") { @@ -68,7 +68,7 @@ class PluginCoverageTest |} """.stripMargin) assert(!compiler.reporter.hasErrors) // we should have 3 statements - initialising the val, executing println, and executing the parameter - compiler.assertNMeasuredStatements(7) + compiler.assertNMeasuredStatements(8) } test("scoverage should not instrument the match as a statement") {