diff --git a/README.md b/README.md index e978adf..ad051a5 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ resolvers += Resolver.jcenterRepo Add the library to a dependency list: ```sbt -libraryDependencies += "com.sizmek.fsi" %% "macros" % "0.2.0" +libraryDependencies += "com.sizmek.fsi" %% "fsi-macros" % "0.2.0" ``` Add import and replace prefix `s` by `fs` (or for a raw string interpolator `raw` by `fraw`): @@ -101,7 +101,8 @@ the following JVM system property: `com.sizmek.fsi.buffer.size`. To compile, run tests, check coverage, and check binary compatibility for different Scala versions use a command: ```sh -sbt clean +coverage +test +coverageReport +mimaReportBinaryIssues +sbt ++2.11.12 clean coverage test coverageReport mimaReportBinaryIssues +sbt ++2.12.6 clean coverage test coverageReport mimaReportBinaryIssues ``` ### Run benchmarks diff --git a/build.sbt b/build.sbt index 7fb2761..65fd077 100644 --- a/build.sbt +++ b/build.sbt @@ -55,7 +55,6 @@ lazy val commonSettings = Seq( "-encoding", "UTF-8", "-feature", "-unchecked", - "-Yno-adapted-args", "-Ywarn-dead-code", "-Xfuture", "-Xlint" @@ -92,38 +91,38 @@ lazy val publishSettings = Seq( ) lazy val `fast-string-interpolator` = project.in(file(".")) - .aggregate(macros, `benchmark-core`, benchmark) + .aggregate(`fsi-macros`, `fsi-benchmark-core`, `fsi-benchmark`) .settings(commonSettings: _*) .settings(noPublishSettings: _*) -lazy val macros = project +lazy val `fsi-macros` = project .settings(commonSettings: _*) .settings(mimaSettings: _*) .settings(publishSettings: _*) .settings( - crossScalaVersions := Seq("2.13.0-M3", "2.12.6", "2.11.12"), + crossScalaVersions := Seq("2.13.0-M4", "2.12.6", "2.11.12"), libraryDependencies ++= Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value, - "org.scalatest" %% "scalatest" % "3.0.5-M1" % Test + "org.scalatest" %% "scalatest" % "3.0.6-SNAP1" % Test ) ) -lazy val `benchmark-core` = project +lazy val `fsi-benchmark-core` = project .enablePlugins(JmhPlugin) - .dependsOn(macros) + .dependsOn(`fsi-macros`) .settings(commonSettings: _*) .settings(noPublishSettings: _*) .settings( - crossScalaVersions := Seq("2.13.0-M3", "2.12.6", "2.11.12"), + crossScalaVersions := Seq("2.13.0-M4", "2.12.6", "2.11.12"), libraryDependencies ++= Seq( "pl.project13.scala" % "sbt-jmh-extras" % "0.3.3", - "org.scalatest" %% "scalatest" % "3.0.5-M1" % Test + "org.scalatest" %% "scalatest" % "3.0.6-SNAP1" % Test ) ) -lazy val benchmark = project +lazy val `fsi-benchmark` = project .enablePlugins(JmhPlugin) - .dependsOn(`benchmark-core`) + .dependsOn(`fsi-benchmark-core`) .settings(commonSettings: _*) .settings(noPublishSettings: _*) .settings( @@ -131,6 +130,7 @@ lazy val benchmark = project libraryDependencies ++= Seq( "com.dongxiguo" %% "fastring" % "1.0.0", "com.outr" %% "perfolation" % "1.0.0", - "org.scalatest" %% "scalatest" % "3.0.5-M1" % Test + "com.outr" %% "scribe-slf4j" % "2.3.4" % Test, + "org.scalatest" %% "scalatest" % "3.0.6-SNAP1" % Test ) ) diff --git a/benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCore.scala b/fsi-benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCore.scala similarity index 100% rename from benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCore.scala rename to fsi-benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCore.scala diff --git a/benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCore.scala b/fsi-benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCore.scala similarity index 100% rename from benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCore.scala rename to fsi-benchmark-core/src/main/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCore.scala diff --git a/benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCoreSpec.scala b/fsi-benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCoreSpec.scala similarity index 100% rename from benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCoreSpec.scala rename to fsi-benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/NestedConcatenationBenchmarkCoreSpec.scala diff --git a/benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCoreSpec.scala b/fsi-benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCoreSpec.scala similarity index 100% rename from benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCoreSpec.scala rename to fsi-benchmark-core/src/test/scala/com/sizmek/fsi/benchmark_core/SimpleConcatenationBenchmarkCoreSpec.scala diff --git a/benchmark/src/main/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmark.scala b/fsi-benchmark/src/main/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmark.scala similarity index 100% rename from benchmark/src/main/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmark.scala rename to fsi-benchmark/src/main/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmark.scala diff --git a/benchmark/src/main/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmark.scala b/fsi-benchmark/src/main/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmark.scala similarity index 100% rename from benchmark/src/main/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmark.scala rename to fsi-benchmark/src/main/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmark.scala diff --git a/fsi-benchmark/src/main/scala/example/BugTest.scala b/fsi-benchmark/src/main/scala/example/BugTest.scala new file mode 100644 index 0000000..66a2f95 --- /dev/null +++ b/fsi-benchmark/src/main/scala/example/BugTest.scala @@ -0,0 +1,23 @@ +package example + +import scala.annotation.compileTimeOnly +import scala.language.experimental.macros +import scala.reflect.macros.blackbox + +class BugTest { + def example(message: => String): LogRecord = macro BugTest.example +} + +@compileTimeOnly("Enable macros to expand") +object BugTest { + def example(c: blackbox.Context)(message: c.Tree): c.Tree = { + import c.universe._ + val f = c.typecheck(q"() => $message") + c.internal.changeOwner(message, c.internal.enclosingOwner, f.symbol) + q"example.LogRecord($f)" + } +} + +case class LogRecord(messageFunction: () => String) { + lazy val message: String = messageFunction() +} \ No newline at end of file diff --git a/benchmark/src/test/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmarkSpec.scala b/fsi-benchmark/src/test/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmarkSpec.scala similarity index 100% rename from benchmark/src/test/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmarkSpec.scala rename to fsi-benchmark/src/test/scala/com/sizmek/fsi/benchmark/NestedConcatenationBenchmarkSpec.scala diff --git a/benchmark/src/test/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmarkSpec.scala b/fsi-benchmark/src/test/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmarkSpec.scala similarity index 100% rename from benchmark/src/test/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmarkSpec.scala rename to fsi-benchmark/src/test/scala/com/sizmek/fsi/benchmark/SimpleConcatenationBenchmarkSpec.scala diff --git a/fsi-benchmark/src/test/scala/example/Test.scala b/fsi-benchmark/src/test/scala/example/Test.scala new file mode 100644 index 0000000..d508f15 --- /dev/null +++ b/fsi-benchmark/src/test/scala/example/Test.scala @@ -0,0 +1,10 @@ +package example + +object Test { + def main(args: Array[String]): Unit = { + val bt = new BugTest + val d = 12.3456 + val record = bt.example(f"Value: $d") + println(s"Record: ${record.message}") + } +} \ No newline at end of file diff --git a/fsi-benchmark/src/test/scala/specs/Issue8Spec.scala b/fsi-benchmark/src/test/scala/specs/Issue8Spec.scala new file mode 100644 index 0000000..1acc8d5 --- /dev/null +++ b/fsi-benchmark/src/test/scala/specs/Issue8Spec.scala @@ -0,0 +1,14 @@ +package specs + +import com.sizmek.fsi._ +import org.scalatest.{Matchers, WordSpec} +import scribe.Logging + +class Issue8Spec extends WordSpec with Matchers with Logging { + "java.util.NoSuchElementException: value d (Issue 8)" should { + "be reproduced" in { + val d = 12.3456 + logger.info(fs"Value: $d") + } + } +} diff --git a/macros/src/main/scala/com/sizmek/fsi/package.scala b/fsi-macros/src/main/scala/com/sizmek/fsi/package.scala similarity index 100% rename from macros/src/main/scala/com/sizmek/fsi/package.scala rename to fsi-macros/src/main/scala/com/sizmek/fsi/package.scala diff --git a/macros/src/test/scala/com/sizmek/specs/fsi/FastStringInterpolatorSpec.scala b/fsi-macros/src/test/scala/com/sizmek/specs/fsi/FastStringInterpolatorSpec.scala similarity index 100% rename from macros/src/test/scala/com/sizmek/specs/fsi/FastStringInterpolatorSpec.scala rename to fsi-macros/src/test/scala/com/sizmek/specs/fsi/FastStringInterpolatorSpec.scala diff --git a/version.sbt b/version.sbt index cfeb331..87c01ed 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.2.1-SNAPSHOT" +version in ThisBuild := "0.3.0-SNAPSHOT"