In Scala 3 summon
seems to do the same thing as the old implicitly
. But when we dig into actual examples we see that isn't the case. For example
case class A(i: Int, s: String)
val mirror = implicitly[Mirror.Of[A]]
type ValueOfs = Tuple.Map[mirror.MirroredElemLabels, ValueOf]
val valueOfs = summonAll[ValueOfs]
def values(t: Tuple): Tuple = t match
case (h: ValueOf[_]) *: t1 => h.value *: values(t1)
case EmptyTuple => EmptyTuple
produces the error
cannot reduce inline match with
scrutinee: compiletime.erasedValue[App.ValueOfs] : App.ValueOfs
patterns : case _:EmptyTuple
case _:*:[t @ _, ts @ _]
However replacing implicitly[Mirror.Of[A]]
with summon[Mirror.Of[A]]
compiles fine.
What are the subtleties of summon
vs implicitly
in this case and in general?