Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot pattern match on quoted invariant type #24189

Copy link
Copy link
@adrien-piquerez-da

Description

@adrien-piquerez-da
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.