diff --git a/build.sbt b/build.sbt index c71c771e7..fe773ab73 100644 --- a/build.sbt +++ b/build.sbt @@ -190,7 +190,8 @@ lazy val zioSchemaThrift = crossProject(JSPlatform, JVMPlatform) .settings(buildInfoSettings("zio.schema.thrift")) .settings( libraryDependencies ++= Seq( - "org.apache.thrift" % "libthrift" % thriftVersion + "org.apache.thrift" % "libthrift" % thriftVersion, + "javax.annotation" % "javax.annotation-api" % javaxAnnotationApiVersion ) ) diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index b55fd07fa..31a10d8be 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -38,6 +38,7 @@ object BuildHelper { val msgpackVersion = "0.9.6" val jacksonScalaVersion = "2.14.2" val thriftVersion = "0.18.1" + val javaxAnnotationApiVersion = "1.3.2" private val testDeps = Seq( "dev.zio" %% "zio-test" % zioVersion % Test, diff --git a/zio-schema-derivation/shared/src/main/scala-2/zio/schema/DeriveSchema.scala b/zio-schema-derivation/shared/src/main/scala-2/zio/schema/DeriveSchema.scala index cac9400be..ebf4bb075 100644 --- a/zio-schema-derivation/shared/src/main/scala-2/zio/schema/DeriveSchema.scala +++ b/zio-schema-derivation/shared/src/main/scala-2/zio/schema/DeriveSchema.scala @@ -589,7 +589,7 @@ object DeriveSchema { val typeArgs = subtypes ++ Iterable(tpe) - val cases = subtypes.map { subtype: Type => + val cases = subtypes.map { (subtype: Type) => @nowarn val typeAnnotations: List[Tree] = subtype.typeSymbol.annotations.collect { diff --git a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/Derive.scala b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/Derive.scala index c33c8cdcf..b4c342f21 100644 --- a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/Derive.scala +++ b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/Derive.scala @@ -14,7 +14,9 @@ object Derive { DeriveInstance().deriveInstance[F, A](deriver, schema, top = true) } -private case class DeriveInstance()(using val ctx: Quotes) extends ReflectionUtils(ctx) { +private case class DeriveInstance()(using val ctx: Quotes) { + val reflectionUtils = ReflectionUtils(ctx) + import reflectionUtils.{MirrorType, Mirror, summonOptional} import ctx.reflect._ case class Frame(ref: Term, tpe: TypeRepr) diff --git a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/DeriveSchema.scala b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/DeriveSchema.scala index 722a23223..55d7a5cf6 100644 --- a/zio-schema-derivation/shared/src/main/scala-3/zio/schema/DeriveSchema.scala +++ b/zio-schema-derivation/shared/src/main/scala-3/zio/schema/DeriveSchema.scala @@ -18,7 +18,9 @@ object DeriveSchema { DeriveSchema().deriveSchema[T](top = true) } -private case class DeriveSchema()(using val ctx: Quotes) extends ReflectionUtils(ctx) { +private case class DeriveSchema()(using val ctx: Quotes) { + val reflectionUtils = ReflectionUtils(ctx) + import reflectionUtils.{MirrorType, Mirror, summonOptional} import ctx.reflect._ case class Frame(ref: Term, tpe: TypeRepr) diff --git a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala index 3c4532424..09a82ce1e 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/Schema.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/Schema.scala @@ -1,6 +1,6 @@ package zio.schema -import java.net.{ URI, URL } +import java.net.URI import java.time.temporal.ChronoUnit import scala.annotation.tailrec @@ -320,7 +320,7 @@ object Schema extends SchemaEquality { Schema[String].transformOrFail( string => try { - Right(new URL(string)) + Right(new URI(string).toURL) } catch { case _: Exception => Left(s"Invalid URL: $string") }, url => Right(url.toString) ) diff --git a/zio-schema/shared/src/main/scala/zio/schema/meta/ExtensibleMetaSchema.scala b/zio-schema/shared/src/main/scala/zio/schema/meta/ExtensibleMetaSchema.scala index d406e2d08..f9d45fa98 100644 --- a/zio-schema/shared/src/main/scala/zio/schema/meta/ExtensibleMetaSchema.scala +++ b/zio-schema/shared/src/main/scala/zio/schema/meta/ExtensibleMetaSchema.scala @@ -616,9 +616,9 @@ object ExtensibleMetaSchema { Schema.Primitive(typ, Chunk.empty) case ExtensibleMetaSchema.FailNode(msg, _, _) => Schema.Fail(msg) case ExtensibleMetaSchema.Ref(refPath, _, _) => - Schema.defer( - refs.getOrElse(refPath, Schema.Fail(s"invalid ref path $refPath")) - ) + def resolve[A](): Schema[A] = + refs.getOrElse(refPath, Schema.Fail(s"invalid ref path $refPath")).asInstanceOf[Schema[A]] + Schema.defer(resolve()) case ExtensibleMetaSchema.Product(id, _, elems, _) => Schema.record( id,