Skip to content

Commit

Permalink
Fix compilation errors with Scala 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Z1kkurat committed Nov 2, 2023
1 parent 5529bd0 commit 3b32ed4
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Message._

class NestedTypeFormatSpec extends JsonFormatSpec {

implicit val messageFormat = {
implicit val messageFormat: OFormat[Message] = {
implicit val noopFormat: OFormat[Noop.type] = new OFormat[Noop.type] {
def writes(o: Noop.type): JsObject = Json.obj()
def reads(json: JsValue): JsResult[Message.Noop.type] = JsSuccess(Message.Noop)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.evolution.playjson.jsoniter

import com.evolution.playjson.jsoniter.TestDataGenerators.{Address, User}
import play.api.libs.json.Json
import play.api.libs.json.{Json, OWrites, Reads}

trait PlayJsonImplicits {

implicit val e = Json.reads[Address]
implicit val f = Json.writes[Address]
implicit val e: Reads[Address] = Json.reads[Address]
implicit val f: OWrites[Address] = Json.writes[Address]

implicit val g = Json.reads[User]
implicit val h = Json.writes[User]
implicit val g: Reads[User] = Json.reads[User]
implicit val h: OWrites[User] = Json.writes[User]

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object PlayJsonWithJsoniterBackendSpec extends org.scalacheck.Properties("PlayJs

implicit def generator: Arbitrary[User] = Arbitrary(genUser)

property("Write using PlayJson -> Read using Jsoniter") = forAll { user: User =>
property("Write using PlayJson -> Read using Jsoniter") = forAll { (user: User) =>
val jsValue = Json.toJson(user)
val bts = Json.toBytes(jsValue)
val actJsValue = PlayJsonJsoniter.deserialize(bts).map(Json.fromJson[User](_))
Expand All @@ -23,7 +23,7 @@ object PlayJsonWithJsoniterBackendSpec extends org.scalacheck.Properties("PlayJs

property("Write using PlayJson -> Read using Jsoniter. Batch") = forAll(
Gen.containerOfN[Vector, User](Size, genUser),
) { batch: Vector[User] =>
) { (batch: Vector[User]) =>
val bools = batch.map { user =>
val jsValue = Json.toJson(user)
val bts = Json.toBytes(jsValue)
Expand All @@ -36,7 +36,7 @@ object PlayJsonWithJsoniterBackendSpec extends org.scalacheck.Properties("PlayJs

property("Write using Jsoniter -> Read using Jsoniter. Batch") = forAll(
Gen.containerOfN[Vector, User](Size, genUser),
) { batch: Vector[User] =>
) { (batch: Vector[User]) =>
val bools = batch.map { user =>
val jsValue = Json.toJson(user)
val bts = PlayJsonJsoniter.serialize(jsValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object RandomJsonArraysSpec extends org.scalacheck.Properties("RandomJsonSpec")
override def overrideParameters(p: Test.Parameters): Test.Parameters =
p.withMinSuccessfulTests(Size)

property("Random json arrays") = forAll { array: value.JsArray =>
property("Random json arrays") = forAll { (array: value.JsArray) =>
val json = array.toString
val jsValue = Json.parse(json)
val bts = PlayJsonJsoniter.serialize(jsValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object RandomJsonObjectsSpec extends org.scalacheck.Properties("RandomJsonObject
override def overrideParameters(p: Test.Parameters): Test.Parameters =
p.withMinSuccessfulTests(Size)

property("Random json objects") = forAll { obj: value.JsObj =>
property("Random json objects") = forAll { (obj: value.JsObj) =>
val json = obj.toString
val jsValue = Json.parse(json)
val bts = PlayJsonJsoniter.serialize(jsValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object PlayJson27xCompat {
implicit def iterableWrites[A, B](implicit ev: B <:< Iterable[A], writes: Writes[A]): Writes[B] = {
Writes[B] { as =>
val builder = mutable.ArrayBuilder.make[JsValue]
as.foreach { a: A => builder += writes.writes(a) }
as.foreach { (a: A) => builder += writes.writes(a) }
JsArray(builder.result())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object PlayJsonHelper {
readStr orElse readNum
}

def writes(o: FiniteDuration) = JsString(o.toCoarsest.toString)
def writes(o: FiniteDuration): JsString = JsString(o.toCoarsest.toString)
}


Expand Down Expand Up @@ -90,7 +90,7 @@ object PlayJsonHelper {
a <- from(a) map { x => JsSuccess(x) } getOrElse JsError(s"No ${ tag.runtimeClass.getName } found for $a")
} yield a

def writes(a: A) = JsString(to(a))
def writes(a: A): JsString = JsString(to(a))
}
}
}
Expand All @@ -107,7 +107,7 @@ object PlayJsonHelper {
a <- from(a) map { x => JsSuccess(x) } getOrElse JsError(s"No ${ tag.runtimeClass.getName } found for $a")
} yield a

def writes(x: A) = JsNumber(to(x))
def writes(x: A): JsNumber = JsNumber(to(x))
}
}
}
Expand Down Expand Up @@ -226,7 +226,7 @@ object PlayJsonHelper {

implicit val writesTuple: Writes[(K, V)] = new Writes[(K, V)] {

def writes(kv: (K, V)) = {
def writes(kv: (K, V)): JsObject = {
val (k, v) = kv
val json = Json.toJson(v) match {
case json: JsObject => json
Expand All @@ -237,7 +237,7 @@ object PlayJsonHelper {
}

new Writes[Map[K, V]] {
def writes(kvs: Map[K, V]) = {
def writes(kvs: Map[K, V]): JsValue = {
Json.toJson(kvs.toList)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest.matchers.should.Matchers
import play.api.libs.json._

class DiscriminatedEitherFormatSpec extends AnyFunSuite with Matchers {
implicit val eitherFormat = DiscriminatedEitherFormat.eitherFormat("L", "R"): OFormat[Either[String, Int]]
implicit val eitherFormat: OFormat[Either[String, Int]] = DiscriminatedEitherFormat.eitherFormat("L", "R"): OFormat[Either[String, Int]]
val left: Either[String, Int] = Left("foo")
val right: Either[String, Int] = Right(1)
val fromEitherJson: JsValue => JsResult[Either[String, Int]] = Json.fromJson[Either[String, Int]](_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TypeFormatSpec extends AnyFunSuite with Matchers {
private val mammalJson = Json.obj("type" -> "Mammal", "legs" -> 4)
private val slothJson = Json.obj("type" -> "Sloth")

implicit val animalFormat = new TypeFormat[Animal] {
implicit val animalFormat: TypeFormat[Animal] = new TypeFormat[Animal] {
val mammalFormat = Json.format[Mammal]
val slothFormat = OFormat.const(Sloth)

Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.6")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11")

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")

Expand Down

0 comments on commit 3b32ed4

Please sign in to comment.