diff --git a/guava/src/main/scala-2/magnolify/guava/FunnelImplicits.scala b/guava/src/main/scala-2/magnolify/guava/FunnelImplicits.scala index 6cd690603..69c9e5233 100644 --- a/guava/src/main/scala-2/magnolify/guava/FunnelImplicits.scala +++ b/guava/src/main/scala-2/magnolify/guava/FunnelImplicits.scala @@ -31,13 +31,13 @@ trait FunnelImplicits { implicit val shortFunnel: Funnel[Short] = FunnelInstances.shortFunnel() implicit def charSequenceFunnel[T <: CharSequence]: Funnel[T] = - FunnelInstances.charSequenceFunnel[T] + FunnelInstances.charSequenceFunnel[T]() // There is an implicit Option[T] => Iterable[T] implicit def iterableFunnel[T, C[_]](implicit fnl: Funnel[T], ti: C[T] => Iterable[T] - ): Funnel[C[T]] = FunnelInstances.iterableFunnel(fnl).contramap(ti) + ): Funnel[C[T]] = FunnelInstances.iterableFunnel(fnl) implicit def funnelOps[T](fnl: Funnel[T]): FunnelOps[T] = new FunnelOps(fnl) } diff --git a/guava/src/main/scala-3/magnolify/guava/FunnelImplicits.scala b/guava/src/main/scala-3/magnolify/guava/FunnelImplicits.scala index 28f4e1eab..5f4b8482b 100644 --- a/guava/src/main/scala-3/magnolify/guava/FunnelImplicits.scala +++ b/guava/src/main/scala-3/magnolify/guava/FunnelImplicits.scala @@ -30,13 +30,13 @@ trait FunnelImplicits: given shortFunnel: Funnel[Short] = FunnelInstances.shortFunnel() given charSequenceFunnel[T <: CharSequence]: Funnel[T] = - FunnelInstances.charSequenceFunnel[T] + FunnelInstances.charSequenceFunnel[T]() // There is an implicit Option[T] => Iterable[T] given iterableFunnel[T, C[_]](using fnl: Funnel[T], ti: C[T] => Iterable[T] - ): Funnel[C[T]] = FunnelInstances.iterableFunnel(fnl).contramap(ti) + ): Funnel[C[T]] = FunnelInstances.iterableFunnel(fnl) extension [T](fnl: Funnel[T]) def contramap[U](f: U => T): Funnel[U] = new Funnel[U]: diff --git a/guava/src/main/scala/magnolify/guava/FunnelInstances.scala b/guava/src/main/scala/magnolify/guava/FunnelInstances.scala index 0a360479d..b286bd985 100644 --- a/guava/src/main/scala/magnolify/guava/FunnelInstances.scala +++ b/guava/src/main/scala/magnolify/guava/FunnelInstances.scala @@ -35,12 +35,14 @@ object FunnelInstances { def charFunnel(): Funnel[Char] = funnel[Char](_.putChar(_)) def shortFunnel(): Funnel[Short] = funnel[Short](_.putShort(_)) - def charSequenceFunnel[T <: CharSequence]: Funnel[T] = + def charSequenceFunnel[T <: CharSequence](): Funnel[T] = Funnels.unencodedCharsFunnel().asInstanceOf[Funnel[T]] - def iterableFunnel[T](fnl: Funnel[T]): Funnel[Iterable[T]] = + + // There is an implicit Option[T] => Iterable[T] + def iterableFunnel[T, C[_]](fnl: Funnel[T])(implicit ti: C[T] => Iterable[T]): Funnel[C[T]] = funnel { (sink, xs) => var i = 0 - xs.foreach { x => + ti(xs).foreach { x => fnl.funnel(x, sink) i += 1 }