Skip to content

Unannotated type matched by annotated type pattern #22773

Open
@prolativ

Description

@prolativ

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)

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