Skip to content

Unannotated type matched by annotated type pattern #22773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
prolativ opened this issue Mar 11, 2025 · 0 comments
Open

Unannotated type matched by annotated type pattern #22773

prolativ opened this issue Mar 11, 2025 · 0 comments
Labels

Comments

@prolativ
Copy link
Contributor

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)
@prolativ prolativ added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:metaprogramming:quotes Issues related to quotes and splices area:annotations and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant