[Scala 3 macro] How to pattern match on quoted invariant type

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?

 case '{
-        type f[X]
         Test.traverse[f, a]($_)
       } =>

this will make it error as expected

Unfortunately there is another bug in Scala 3.3 that prevents me from removing the type variable:

[error] Type argument f does not conform to upper bound [_] =>> Any
[error]         Test.traverse[f, a]($_)

That’s why I added it in the first place