Skip to content

Cannot pattern match on quoted invariant type #24189

@adrien-piquerez-da

Description

@adrien-piquerez-da

Compiler version

3.3.6 and 3.7.3

Minimized code

// 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 _ => '{}

Output

It compiles.

Expectation

It should fail with do not use traverse error on traverse[Foo, Int](Foo[Int]).

Notes

It works as expected if Foo is covariant: class Foo[+A].

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions