diff --git a/project/NeoJmhPlugin.scala b/project/NeoJmhPlugin.scala index 05a51e66e..a831c348b 100644 --- a/project/NeoJmhPlugin.scala +++ b/project/NeoJmhPlugin.scala @@ -52,7 +52,7 @@ object NeoJmhPlugin extends AutoPlugin { override def projectSettings = inConfig(Jmh)( Defaults.testSettings ++ Seq( - run := (run in JmhInternal).evaluated, + run := (JmhInternal / run).evaluated, neoJmhGenerator := "reflection", neoJmhYourkit := Nil, javaOptions ++= Seq( @@ -71,11 +71,11 @@ object NeoJmhPlugin extends AutoPlugin { ) ) ++ inConfig(JmhInternal)( Defaults.testSettings ++ Seq( - javaOptions := (javaOptions in Jmh).value, - envVars := (envVars in Jmh).value, - mainClass in run := Some("org.openjdk.jmh.Main"), - fork in run := true, - dependencyClasspath ++= (fullClasspath in Jmh).value, + javaOptions := (Jmh / javaOptions).value, + envVars := (Jmh / envVars).value, + run / mainClass := Some("org.openjdk.jmh.Main"), + run / fork := true, + dependencyClasspath ++= (Jmh / fullClasspath).value, sourceGenerators += generateJmhSourcesAndResources.map { case (sources, _) => sources }, @@ -106,23 +106,23 @@ object NeoJmhPlugin extends AutoPlugin { def backCompatProjectSettings: Seq[Setting[_]] = Seq( // WORKAROUND https://github.com/sbt/sbt/issues/3935 - dependencyClasspathAsJars in NeoJmhPlugin.JmhInternal ++= (fullClasspathAsJars in NeoJmhKeys.Jmh).value + NeoJmhPlugin.JmhInternal / dependencyClasspathAsJars ++= (NeoJmhKeys.Jmh / fullClasspathAsJars).value ) def generateBenchmarkSourcesAndResources: Def.Initialize[Task[(Seq[File], Seq[File])]] = Def.task { val s = streams.value val cacheDir = crossTarget.value / "jmh-cache" - val bytecodeDir = (classDirectory in Jmh).value + val bytecodeDir = (Jmh / classDirectory).value val sourceDir = sourceManaged.value val resourceDir = resourceManaged.value - val generator = (neoJmhGenerator in Jmh).value + val generator = (Jmh / neoJmhGenerator).value val classpath = dependencyClasspath.value - val javaHomeV = (javaHome in Jmh).value - val outputStrategyV = (outputStrategy in Jmh).value - val workingDirectory = Option((baseDirectory in Jmh).value) - val connectInputV = (connectInput in Jmh).value - val envVarsV = (envVars in Jmh).value - val javaFlags = (javaOptions in Jmh).value.toVector + val javaHomeV = (Jmh / javaHome).value + val outputStrategyV = (Jmh / outputStrategy).value + val workingDirectory = Option((Jmh / baseDirectory).value) + val connectInputV = (Jmh / connectInput).value + val envVarsV = (Jmh / envVars).value + val javaFlags = (Jmh / javaOptions).value.toVector val inputs: Set[File] = (bytecodeDir ** "*").filter(_.isFile).get.toSet val cachedGeneration = FileFunction.cached(cacheDir, FilesInfo.hash) { _ => diff --git a/zio-json/jvm/src/jmh/scala/zio/json/UUIDBenchmarks.scala b/zio-json/jvm/src/jmh/scala/zio/json/UUIDBenchmarks.scala index 6b987e219..3912c108a 100644 --- a/zio-json/jvm/src/jmh/scala/zio/json/UUIDBenchmarks.scala +++ b/zio-json/jvm/src/jmh/scala/zio/json/UUIDBenchmarks.scala @@ -30,7 +30,7 @@ class UUIDBenchmarks { } yield s"$s1-$s2-$s3-$s4-$s5" unparsedUUIDChunk = { - Unsafe.unsafeCompat { implicit u => + Unsafe.unsafe { implicit u => zio.Runtime.default.unsafe.run(gen.runCollectN(10000).map(Chunk.fromIterable)).getOrThrow() } } diff --git a/zio-json/jvm/src/main/scala/zio/json/JsonDecoderPlatformSpecific.scala b/zio-json/jvm/src/main/scala/zio/json/JsonDecoderPlatformSpecific.scala index 3394cf0d5..11da0dbfd 100644 --- a/zio-json/jvm/src/main/scala/zio/json/JsonDecoderPlatformSpecific.scala +++ b/zio-json/jvm/src/main/scala/zio/json/JsonDecoderPlatformSpecific.scala @@ -54,7 +54,7 @@ trait JsonDecoderPlatformSpecific[A] { self: JsonDecoder[A] => final def decodeJsonPipeline( delimiter: JsonStreamDelimiter = JsonStreamDelimiter.Array ): ZPipeline[Any, Throwable, Char, A] = { - Unsafe.unsafeCompat { (u: Unsafe) => + Unsafe.unsafe { (u: Unsafe) => implicit val unsafe: Unsafe = u ZPipeline.fromPush { @@ -121,7 +121,7 @@ trait JsonDecoderPlatformSpecific[A] { self: JsonDecoder[A] => throw new Exception(JsonError.render(trace)) } - Unsafe.unsafeCompat { (u: Unsafe) => + Unsafe.unsafe { (u: Unsafe) => implicit val unsafe: Unsafe = u runtime.unsafe.run(outQueue.offer(Take.single(nextElem))).getOrThrow() diff --git a/zio-json/jvm/src/main/scala/zio/json/JsonEncoderPlatformSpecific.scala b/zio-json/jvm/src/main/scala/zio/json/JsonEncoderPlatformSpecific.scala index bd4b995f6..516fc41fd 100644 --- a/zio-json/jvm/src/main/scala/zio/json/JsonEncoderPlatformSpecific.scala +++ b/zio-json/jvm/src/main/scala/zio/json/JsonEncoderPlatformSpecific.scala @@ -17,7 +17,7 @@ trait JsonEncoderPlatformSpecific[A] { self: JsonEncoder[A] => delimiter: Option[Char], endWith: Option[Char] ): ZPipeline[Any, Throwable, A, Char] = - Unsafe.unsafeCompat { (u: Unsafe) => + Unsafe.unsafe { (u: Unsafe) => implicit val unsafe: Unsafe = u ZPipeline.fromPush { diff --git a/zio-json/shared/src/main/scala-2.x/zio/json/macros.scala b/zio-json/shared/src/main/scala-2.x/zio/json/macros.scala index 3810b8c58..6be618f0e 100644 --- a/zio-json/shared/src/main/scala-2.x/zio/json/macros.scala +++ b/zio-json/shared/src/main/scala-2.x/zio/json/macros.scala @@ -9,7 +9,6 @@ import zio.json.ast.Json import zio.json.internal.{ Lexer, RetractReader, StringMatrix, Write } import scala.annotation._ -import scala.collection.mutable import scala.language.experimental.macros /** @@ -309,7 +308,7 @@ object DeriveJsonDecoder { val len: Int = names.length val matrix: StringMatrix = new StringMatrix(names, aliases) - val spans: Array[JsonError] = names.map(JsonError.ObjectAccess(_)) + val spans: Array[JsonError] = names.map(JsonError.ObjectAccess) lazy val tcs: Array[JsonDecoder[Any]] = ctx.parameters.map(_.typeclass).toArray.asInstanceOf[Array[JsonDecoder[Any]]] lazy val defaults: Array[Option[Any]] = @@ -431,7 +430,7 @@ object DeriveJsonDecoder { ctx.annotations.collectFirst { case jsonDiscriminator(n) => n }.orElse(config.sumTypeHandling.discriminatorField) if (discrim.isEmpty) new JsonDecoder[A] { - val spans: Array[JsonError] = names.map(JsonError.ObjectAccess(_)) + val spans: Array[JsonError] = names.map(JsonError.ObjectAccess) def unsafeDecode(trace: List[JsonError], in: RetractReader): A = { Lexer.char(trace, in, '{') // we're not allowing extra fields in this encoding @@ -469,7 +468,7 @@ object DeriveJsonDecoder { new JsonDecoder[A] { val hintfield = discrim.get val hintmatrix = new StringMatrix(Array(hintfield)) - val spans: Array[JsonError] = names.map(JsonError.Message(_)) + val spans: Array[JsonError] = names.map(JsonError.Message) def unsafeDecode(trace: List[JsonError], in: RetractReader): A = { val in_ = internal.RecordingReader(in) diff --git a/zio-json/shared/src/main/scala/zio/json/JsonEncoder.scala b/zio-json/shared/src/main/scala/zio/json/JsonEncoder.scala index d118674de..cb2882b56 100644 --- a/zio-json/shared/src/main/scala/zio/json/JsonEncoder.scala +++ b/zio-json/shared/src/main/scala/zio/json/JsonEncoder.scala @@ -80,7 +80,6 @@ trait JsonEncoder[A] extends JsonEncoderPlatformSpecific[A] { * This default may be overridden when this value may be missing within a JSON object and still * be encoded. */ - @nowarn("msg=is never used") def isNothing(a: A): Boolean = false /** diff --git a/zio-json/shared/src/main/scala/zio/json/ast/ast.scala b/zio-json/shared/src/main/scala/zio/json/ast/ast.scala index d251165f6..5d2f1f900 100644 --- a/zio-json/shared/src/main/scala/zio/json/ast/ast.scala +++ b/zio-json/shared/src/main/scala/zio/json/ast/ast.scala @@ -493,7 +493,7 @@ object Json { def apply(value: Int): Num = Num(BigDecimal(value).bigDecimal) def apply(value: Long): Num = Num(BigDecimal(value).bigDecimal) def apply(value: BigDecimal): Num = Num(value.bigDecimal) - def apply(value: Float): Num = Num(BigDecimal(value).bigDecimal) + def apply(value: Float): Num = Num(BigDecimal.decimal(value).bigDecimal) def apply(value: Double): Num = Num(BigDecimal(value).bigDecimal) implicit val decoder: JsonDecoder[Num] = new JsonDecoder[Num] { diff --git a/zio-json/shared/src/test/scala/zio/json/CodecSpec.scala b/zio-json/shared/src/test/scala/zio/json/CodecSpec.scala index c05d08986..2e2c5a12f 100644 --- a/zio-json/shared/src/test/scala/zio/json/CodecSpec.scala +++ b/zio-json/shared/src/test/scala/zio/json/CodecSpec.scala @@ -92,7 +92,6 @@ object CodecSpec extends ZIOSpecDefault { val snaked = """{"indiana123_jones":""}""" val pascaled = """{"Anders123Hejlsberg":""}""" val cameled = """{"small123Talk":""}""" - val indianaJones = """{"wHATcASEiStHIS":""}""" val overrides = """{"not_modified":"","but-this-should-be":0}""" val kebabedLegacy = """{"shish-123-kebab":""}""" val snakedLegacy = """{"indiana_123_jones":""}""" diff --git a/zio-json/shared/src/test/scala/zio/json/DecoderSpec.scala b/zio-json/shared/src/test/scala/zio/json/DecoderSpec.scala index 358352882..e2fd0b796 100644 --- a/zio-json/shared/src/test/scala/zio/json/DecoderSpec.scala +++ b/zio-json/shared/src/test/scala/zio/json/DecoderSpec.scala @@ -5,7 +5,7 @@ import zio.json._ import zio.json.ast.Json import zio.test.Assertion._ import zio.test.TestAspect.jvmOnly -import zio.test.{ TestAspect, _ } +import zio.test._ import java.time.{ Duration, OffsetDateTime, ZonedDateTime } import java.util.UUID