Hello all,
I tried this:
// In Test.scala
//> using scala 3.7.3
class Foo[A]
object Test:
def traverse[F[_], A](x: F[A]): F[Any] = ???
Macro.test(traverse[Foo, Int](Foo[Int]))
// In Macro.scala
import scala.quoted.*
object Macro:
inline def test(inline x: Any): Unit = ${ test('x) }
private def test(x: Expr[Any])(using Quotes): Expr[Unit] =
x match
case '{
type f[X]
Test.traverse[f, a]($_)
} =>
quotes.reflect.report.errorAndAbort("do not use traverse", x)
case _ => '{}
I expect it to fail with do not use traverse but it compiles without an error.
However, if I declare Foo as class Foo[+A], the macro works as expected and I get the compilation error.
How can I make this to work with a invariant type? Is this a bug?