I guess self-recursive types are well-known in Scala. A nice intro can be found at here. The following piece of code is taken from that page:
trait Doubler[T <: Doubler[T]] { self: T =>
def double: T
}
In Scala 3 Macros, we can match on types, introduced with examples on this page (right before "Quote types patterns" Section). However, I still don't know how to match self-recursive types. Any idea?
Imagine that I have the following method:
def doSomething[T <: Doubler[T]](value: T): Unit = { ... }
And the following macro:
inline def myMacro[A](inline value: A): Unit = ${ myMacroImpl('value) }
private def myMacroImpl[A: Type](value: Expr[A])(using q: Quotes): Expr[Unit] =
import q.reflect.*
value match
case '{ $x: /*help-me*/ } => '{ doSomething($x) }
case _ => // irrelevant
How should I fix the first case to make the code even compile?