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 7e4e3fb77..b41711c30 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 @@ -121,7 +121,7 @@ private case class DeriveSchema()(using val ctx: Quotes) { val selfRefSymbol = Symbol.newVal(Symbol.spliceOwner, s"derivedSchema${stack.size}", TypeRepr.of[Schema[T]], Flags.Lazy, Symbol.noSymbol) val selfRef = Ref(selfRefSymbol) - val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].show)})} + val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].classSymbol.get.fullName.replaceAll("\\$", ""))})} val isEnumCase = Type.of[T] match { case '[reflect.Enum] => true case _ => false @@ -201,7 +201,7 @@ private case class DeriveSchema()(using val ctx: Quotes) { List('{zio.schema.annotation.genericTypeInfo(ListMap.from(${typeMembersExpr}.zip(${typeArgsExpr}.map(name => TypeId.parse(name).asInstanceOf[TypeId.Nominal]))))}) } else List.empty val annotations = '{ zio.Chunk.fromIterable(${Expr.ofSeq(annotationExprs)}) ++ zio.Chunk.fromIterable(${Expr.ofSeq(docAnnotationExpr)}) ++ zio.Chunk.fromIterable(${Expr.ofSeq(genericAnnotations)}) } - val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].show)})} + val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].classSymbol.get.fullName.replaceAll("\\$", ""))})} val applied = if (labels.length <= 22) { @@ -390,7 +390,7 @@ private case class DeriveSchema()(using val ctx: Quotes) { } else List.empty val annotations = '{ zio.Chunk.fromIterable(${Expr.ofSeq(annotationExprs)}) ++ zio.Chunk.fromIterable(${Expr.ofSeq(docAnnotationExpr.toList)}) ++ zio.Chunk.fromIterable(${Expr.ofSeq(genericAnnotations)}) } - val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].show)})} + val typeInfo = '{TypeId.parse(${Expr(TypeRepr.of[T].classSymbol.get.fullName.replaceAll("\\$", ""))})} val applied = if (cases.length <= 22) { val args = List(typeInfo) ++ cases :+ annotations diff --git a/zio-schema-derivation/shared/src/test/scala/zio/schema/DeriveSpec.scala b/zio-schema-derivation/shared/src/test/scala/zio/schema/DeriveSpec.scala index 51a222e08..a4467831a 100644 --- a/zio-schema-derivation/shared/src/test/scala/zio/schema/DeriveSpec.scala +++ b/zio-schema-derivation/shared/src/test/scala/zio/schema/DeriveSpec.scala @@ -189,6 +189,9 @@ import zio.{ Chunk, Scope } maybeTypeInfo.contains( genericTypeInfo(ListMap("T" -> TypeId.parse("scala.Int").asInstanceOf[TypeId.Nominal])) ), + capturedSchema.schema.asInstanceOf[Schema.Record[GenericRecordWithDefaultValue[Int]]].id == TypeId.parse( + "zio.schema.DeriveSpec.GenericRecordWithDefaultValue" + ), annotations.exists { a => a.isInstanceOf[fieldDefaultValue[_]] && a.asInstanceOf[fieldDefaultValue[Option[Int]]].value == None diff --git a/zio-schema/jvm/src/main/scala/zio/schema/SchemaPlatformSpecific.scala b/zio-schema/jvm/src/main/scala/zio/schema/SchemaPlatformSpecific.scala index f256da2da..faef5f72d 100644 --- a/zio-schema/jvm/src/main/scala/zio/schema/SchemaPlatformSpecific.scala +++ b/zio-schema/jvm/src/main/scala/zio/schema/SchemaPlatformSpecific.scala @@ -6,7 +6,7 @@ trait SchemaPlatformSpecific { Schema[String].transformOrFail( string => try { - Right(new java.net.URL(string)) + Right(new java.net.URI(string).toURL) } catch { case _: Exception => Left(s"Invalid URL: $string") }, url => Right(url.toString) )