scala/scala3

Unannotated type matched by annotated type pattern

Opened this issue · 0 comments

Compiler version

3.3.5, 3.6.4, 3.7.0-RC1-bin-20250309-2f639e2-NIGHTLY

Minimized code

Lib.scala:

import scala.quoted.*

class myAnnot extends scala.annotation.StaticAnnotation

inline def myAnnotValue[A]: Option[String] = ${ myAnnotValueImpl[A] }

def myAnnotValueImpl[A : Type](using Quotes): Expr[Option[String]] =
  Type.of[A] match
    case '[t @ `myAnnot`] => '{ Some("xyz") }
    case _ => '{ None }

Test.scala

@main def run() =
  println(myAnnotValue[Int])
  println(myAnnotValue[Int @myAnnot])

Output

Some(xyz)
Some(xyz)

Expectation

None
Some(xyz)