Do we have any replacement for the following Scala 3.7 code:
x.asType match {
case '[type t <: S; t] =>
'{ apply[t] }.asExprOf[Any]
case _ =>
report.errorAndAbort(s"Expected $x to be a sub-type of ${TypeRepr.of[S]}",Position.ofMacroExpansion)
}
in Scala 3.3.6 (the latest LTS release)?
Try
'{...}
rather than type quotations '[...]
x.asType match {
case '[t] => '{tag[t]} match {
case '{type t1 <: S; tag[`t1`]} =>
'{ apply[t1] }.asExprOf[Any]
}
for a dummy method
// outside macro impl
def tag[A] = ???
... & S
x.asType match {
case '[t] =>
'{ apply[t & S] }.asExprOf[Any]
type SBounded[T <: S] = T
x.asType match {
case '[SBounded[t]] =>
'{ apply[t] }.asExprOf[Any]
In scala 3.6.4, how to call a polymorphic method with type bounds from inside a quoted expression?