Skip to content

Commit

Permalink
fix some warnings. (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
counter2015 authored Apr 24, 2024
1 parent e1f34bd commit 0cd8bb8
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 27 deletions.
30 changes: 15 additions & 15 deletions project/NeoJmhPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
},
Expand Down Expand Up @@ -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) { _ =>
Expand Down
2 changes: 1 addition & 1 deletion zio-json/jvm/src/jmh/scala/zio/json/UUIDBenchmarks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions zio-json/shared/src/main/scala-2.x/zio/json/macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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]] =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion zio-json/shared/src/main/scala/zio/json/JsonEncoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
2 changes: 1 addition & 1 deletion zio-json/shared/src/main/scala/zio/json/ast/ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
1 change: 0 additions & 1 deletion zio-json/shared/src/test/scala/zio/json/CodecSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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":""}"""
Expand Down
2 changes: 1 addition & 1 deletion zio-json/shared/src/test/scala/zio/json/DecoderSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0cd8bb8

Please sign in to comment.