Skip to content

pattern selector should be an instance of Matchable when matching on Quotes Reflect API #22623

@goshacodes

Description

@goshacodes

Compiler version

3.4.3 + -source:future

Minimized example

main.scala

Example.matchableExample

example.scala

import scala.quoted.*

object Example:
  inline def matchableExample: Unit = ${ matchableExampleMacro }

  def matchableExampleMacro(using quotes: Quotes): Expr[Unit] = {
    import quotes.reflect.*
    val tpe = TypeRepr.of[Int]
    tpe match
      case OrType(left, right) =>
        println(s"OrType: $left, $right")
      case other =>
        println(s"other: $other")
    '{}
  }

Output Error/Warning message

[warn] 10 |      case OrType(left, right) =>
[warn]    |           ^^^^^^^^^^^^^^^^^^^
[warn]    |           pattern selector should be an instance of Matchable,,
[warn]    |           but it has unmatchable type quotes.reflect.TypeRepr instead

Why this Error/Warning was not helpful

As I understood there should be no warning at all.

Suggested improvement

Make Quotes API subtype of Matchable

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:metaprogramming:quotesIssues related to quotes and splicesarea:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancementstat:fixed in nextThe issue was fixed in Next and only still applies to LTS.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions