Replace delegate match with summonFrom. by odersky · Pull Request #7201 · scala/scala3 (original) (raw)

Instead of having a separate syntactic construct (latest incarnation: delegate match), provide
a special method summonFrom in scala.compiletime.

delegate match { case ev_1: TC_1 => e_1 ... case ev_n: TC_n => e_n }

becomes

summonFrom { case given ev_1: TC_1 => e_1 ... case given ev_n: TC_n => e_n }

summonFrom is currently implemented by compiler magic. It could be implemented as a macro if we introduce an additional way to control when inline methods expand. See the comment in Applications.scala.

Based on #7194.