(Copied here from Discord where I didn’t get a reaction.)
In Scastie - An interactive playground for Scala., I have a working example of a Show
typeclass that works for any Product
. Now I’d like to rewrite the given
using with
notation:
inline given productShow[T](using m: Mirror.ProductOf[T]): Show[T] with // =
// new Show[T]:
def show(t: T): String = {
val shows = summonAllShows[m.MirroredElemTypes]
(t.asInstanceOf[Product].productIterator).zip(shows.iterator).map {
case (p, s) => s.asInstanceOf[Show[Any]].show(p)
}.mkString
}
I thought this would be 100% equivalent, but I get
method summonAllShows is declared as `inline`, but was not inlined
Try increasing `-Xmax-inlines` above 32
If I declare show
as inline
, I get
(productShow.this.inline$m : => deriving.Mirror.ProductOf[T]) is not a legal path
since it refers to nonfinal method inline$m
Any ideas how to use the with
style?
Thanks,
Cay