From 430ca876470de5f6ba5ba53ff656f14bbc46fe83 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 16 Oct 2024 16:20:25 +0000 Subject: [PATCH 1/3] Update scala3-library, ... to 3.3.4 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c0c1a9c0..03061981 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ import scala.scalanative.build._ val scala212 = "2.12.20" val scala213 = "2.13.15" -val scala3 = "3.3.3" +val scala3 = "3.3.4" val fs2Version = "3.11.0" val circeVersion = "0.14.8" val circeExtrasVersion = "0.14.2" From 8aaafe5da69030fa8161631df40e10ebf4fdb753 Mon Sep 17 00:00:00 2001 From: Lucas Satabin Date: Sun, 20 Oct 2024 15:24:08 +0200 Subject: [PATCH 2/3] Ignore deprecation warning --- text/shared/src/main/scala/fs2/data/text/CharLikeChunks.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/text/shared/src/main/scala/fs2/data/text/CharLikeChunks.scala b/text/shared/src/main/scala/fs2/data/text/CharLikeChunks.scala index 3394a9e4..74294a60 100644 --- a/text/shared/src/main/scala/fs2/data/text/CharLikeChunks.scala +++ b/text/shared/src/main/scala/fs2/data/text/CharLikeChunks.scala @@ -18,9 +18,10 @@ package fs2 package data package text -import scala.annotation.implicitNotFound +import org.typelevel.scalaccompat.annotation.* import java.nio.charset.Charset +import scala.annotation.implicitNotFound /** A typeclass witnessing that a stream of type `In` has chunks * that can be iterated over to get characters. @@ -74,6 +75,7 @@ trait CharLikeChunks[F[_], In] { } +@nowarn3("cat=deprecation") sealed trait AsCharBuffer[F[_], T] extends CharLikeChunks[F, T] { def mark(ctx: Context): Unit From 04fcad93a9c05f9dd89962f4acd6f38431758eb2 Mon Sep 17 00:00:00 2001 From: Lucas Satabin Date: Mon, 21 Oct 2024 13:55:23 +0200 Subject: [PATCH 3/3] Avoid redeclaring inlined classes --- .../data/csv/generic/internal/CellValue.scala | 10 ++++++++-- .../generic/internal/DerivedCellDecoder.scala | 10 ++++++---- .../generic/internal/DerivedCellEncoder.scala | 16 +++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/CellValue.scala b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/CellValue.scala index f2485a45..f4fee6a9 100644 --- a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/CellValue.scala +++ b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/CellValue.scala @@ -26,10 +26,16 @@ trait CellValue[T] { def value: String } +private class AnnotationCellValue[T](a: Annotation[CsvValue, T]) extends CellValue[T] { + def value: String = a().value +} + +private class ConstantCellValue[T](val value: String) extends CellValue[T] + object CellValue { inline given deriveSingleton[T](using m: Mirror.ProductOf[T] { type MirroredElemTypes = EmptyTuple }): CellValue[T] = summonFrom { - case a: Annotation[CsvValue, T] => new CellValue[T] { def value: String = a().value } - case _ => new CellValue[T] { def value: String = constValue[m.MirroredLabel] } + case a: Annotation[CsvValue, T] => new AnnotationCellValue[T](a) + case _ => new ConstantCellValue[T](constValue[m.MirroredLabel]) } } diff --git a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellDecoder.scala b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellDecoder.scala index 038e5de2..37ba6a8b 100644 --- a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellDecoder.scala +++ b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellDecoder.scala @@ -25,6 +25,11 @@ import scala.deriving.Mirror trait DerivedCellDecoder[T] extends CellDecoder[T] +private class CoproductDerivedCellDecoder[T](decoders: List[DerivedCellDecoder[T]]) extends DerivedCellDecoder[T] { + def apply(in: String) = + decoders.foldRight(new DecoderError("Didn't match any value").asLeft)(_.apply(in).orElse(_)) +} + object DerivedCellDecoder { def expect[T](e: String, r: T): DerivedCellDecoder[T] = (in: String) => Either.cond(in == e, r, new DecoderError(s"Expected $e, got $in")) @@ -38,10 +43,7 @@ object DerivedCellDecoder { inline given deriveCoproduct[T](using m: Mirror.SumOf[T]): DerivedCellDecoder[T] = { val decoders: List[DerivedCellDecoder[T]] = summonAsArray[K0.LiftP[DerivedCellDecoder, m.MirroredElemTypes]].toList.asInstanceOf - new DerivedCellDecoder[T] { - def apply(in: String) = - decoders.foldRight(new DecoderError("Didn't match any value").asLeft)(_.apply(in).orElse(_)) - } + new CoproductDerivedCellDecoder[T](decoders) } inline given deriveSingleton[T](using cv: CellValue[T], m: Mirror.ProductOf[T]): DerivedCellDecoder[T] = diff --git a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellEncoder.scala b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellEncoder.scala index 5ee4dfa0..44b90d37 100644 --- a/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellEncoder.scala +++ b/csv/generic/shared/src/main/scala-3/fs2/data/csv/generic/internal/DerivedCellEncoder.scala @@ -31,14 +31,12 @@ object DerivedCellEncoder { ce(t.productElement(0).asInstanceOf[Tuple.Head[m.MirroredElemTypes]]) } - inline given deriveCoproduct[T](using g: K0.CoproductInstances[DerivedCellEncoder, T]): DerivedCellEncoder[T] = - new DerivedCellEncoder[T] { - def apply(elem: T) = g.fold(elem)([t <: T] => (dce: DerivedCellEncoder[t], te: t) => dce(te)) - } - - inline given deriveSingleton[T](using cv: CellValue[T]): DerivedCellEncoder[T] = - new DerivedCellEncoder[T] { - def apply(t: T) = cv.value - } + inline given deriveCoproduct[T](using g: K0.CoproductInstances[DerivedCellEncoder, T]): DerivedCellEncoder[T] with { + def apply(elem: T) = g.fold(elem)([t <: T] => (dce: DerivedCellEncoder[t], te: t) => dce(te)) + } + + inline given deriveSingleton[T](using cv: CellValue[T]): DerivedCellEncoder[T] with { + def apply(t: T) = cv.value + } }