diff --git a/build.sbt b/build.sbt index c0c1a9c0a..03061981d 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" 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 f2485a45a..f4fee6a90 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 038e5de26..37ba6a8b8 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 5ee4dfa08..44b90d37d 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 + } } 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 3394a9e4c..74294a60e 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