Skip to content

Cannot extract annotation parameter from annotated type in a macro #22774

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 · 3 comments
Open

Cannot extract annotation parameter from annotated type in a macro #22774

prolativ opened this issue Mar 11, 2025 · 3 comments
Assignees

Comments

@prolativ
Copy link
Contributor

prolativ commented Mar 11, 2025

Compiler version

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

Minimized code

Lib1.scala:

import scala.quoted.*

class myAnnot(value: String) 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`($value)] => '{ Some($value) }
    case _ => '{ None }

Lib2.scala:

import scala.quoted.*

class myAnnot(value: String) 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($value)] => '{ Some($value) }
    case _ => '{ None }

Test.scala:

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

Output: compiling Lib1.scala and Test.scala

[error] /tmp/repro/Test.scala:2:11
[error] Exception occurred while executing macro expansion.
[error] java.lang.ClassCastException: class scala.Tuple1 cannot be cast to class scala.Tuple2 (scala.Tuple1 and scala.Tuple2 are in unnamed module of loader java.net.URLClassLoader @34c5425e)
[error]         at Lib$package$.myAnnotValueImpl(Lib.scala:9)
[error] 
[error]   println(myAnnotValue[Int])
[error]           ^^^^^^^^^^^^^^^^^

Output: compiling Lib2.scala and Test.scala (click arrow to expand)

[error] /tmp/repro/Lib.scala:9:14
[error] myAnnot does not have a constructor
[error]     case '[t @ myAnnot($value)] => '{ Some($value) }
[error]              ^^^^^^^^^
[error] /tmp/repro/Lib.scala:9:25
[error] Type must be fully defined.
[error] Consider annotating the splice using a type ascription:
[error]   (${value}: XYZ).
[error]     case '[t @ myAnnot($value)] => '{ Some($value) }
[error]                         ^^^^^

  exception occurred while typechecking /tmp/repro/Lib.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.


     while compiling: /tmp/repro/Lib.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.16
    compiler version: version 3.7.0-RC1-bin-20250309-2f639e2-NIGHTLY-git-2f639e2
            settings: -bootclasspath /Users/mpalka/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.7.0-RC1-bin-20250309-2f639e2-NIGHTLY/scala3-library_3-3.7.0-RC1-bin-20250309-2f639e2-NIGHTLY.jar:/Users/mpalka/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar -classpath /private/tmp/repro/.scala-build/.bloop/repro_84fb2551f9/bloop-internal-classes/main-N30Q9UncQOWeS1L0ZinWng==:/private/tmp/repro/.scala-build/.bloop/repro_84fb2551f9/bloop-internal-classes/main-m0yvuymsT9uNMAv4bHWfHg== -d /private/tmp/repro/.scala-build/.bloop/repro_84fb2551f9/bloop-internal-classes/main-N30Q9UncQOWeS1L0ZinWng== -java-output-version 11 -sourceroot /tmp/repro

Error compiling project (Scala 3.7.0-RC1-bin-20250309-2f639e2-NIGHTLY, JVM (11))
Error: dotty.tools.dotc.ast.Trees$UnAssignedTypeException: type of Ident(value) is not assigned
        at dotty.tools.dotc.ast.Trees$Tree.tpe(Trees.scala:74)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:67)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:64)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1781)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:68)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:64)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1668)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1670)
        at dotty.tools.dotc.core.Annotations$Annotation.mapWith(Annotations.scala:69)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6228)
        at dotty.tools.dotc.typer.Typer$$anon$6.apply(Typer.scala:2226)
        at dotty.tools.dotc.core.Types$TypeMap.op$proxy18$1(Types.scala:6143)
        at dotty.tools.dotc.core.Types$TypeMap.mapArg(Types.scala:6143)
        at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:6147)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6203)
        at dotty.tools.dotc.typer.Typer$$anon$6.apply(Typer.scala:2226)
        at dotty.tools.dotc.typer.Typer$$anon$5.transform(Typer.scala:2229)
        at dotty.tools.dotc.typer.Typer.caseRest$1(Typer.scala:2266)
        at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:2289)
        at dotty.tools.dotc.typer.Typer.typedCases$$anonfun$1(Typer.scala:2212)
        at dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99)
        at dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115)
        at dotty.tools.dotc.typer.Typer.typedCases(Typer.scala:2211)
        at dotty.tools.dotc.typer.Typer.$anonfun$39(Typer.scala:2194)
        at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:2662)
        at dotty.tools.dotc.typer.Applications.harmonic$(Applications.scala:465)
        at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:154)
        at dotty.tools.dotc.typer.Typer.typedMatchFinish(Typer.scala:2194)
        at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:2122)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3588)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3658)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3851)
        at dotty.tools.dotc.typer.Typer.$anonfun$66(Typer.scala:2968)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2968)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3555)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3657)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3762)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3808)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3236)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3561)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3565)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3657)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3762)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3808)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3369)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3607)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3658)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3851)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:510)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:346)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1324)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:339)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:386)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:386)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.Run.showProgress(Run.scala:448)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:386)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:398)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:398)
        at dotty.tools.dotc.Run.compileSources(Run.scala:285)
        at dotty.tools.dotc.Run.compile(Run.scala:270)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
        at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:148)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:181)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:73)
        at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:72)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:181)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
        at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
        at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
        at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Error: Unexpected error when compiling repro_84fb2551f9: dotty.tools.dotc.ast.Trees$UnAssignedTypeException: type of Ident(value) is not assigned
        at dotty.tools.dotc.ast.Trees$Tree.tpe(Trees.scala:74)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:67)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:64)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1781)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:68)
        at dotty.tools.dotc.core.Annotations$Annotation$$anon$1.apply(Annotations.scala:64)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.fold$1(Trees.scala:1668)
        at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1670)
        at dotty.tools.dotc.core.Annotations$Annotation.mapWith(Annotations.scala:69)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6228)
        at dotty.tools.dotc.typer.Typer$$anon$6.apply(Typer.scala:2226)
        at dotty.tools.dotc.core.Types$TypeMap.op$proxy18$1(Types.scala:6143)
        at dotty.tools.dotc.core.Types$TypeMap.mapArg(Types.scala:6143)
        at dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:6147)
        at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6203)
        at dotty.tools.dotc.typer.Typer$$anon$6.apply(Typer.scala:2226)
        at dotty.tools.dotc.typer.Typer$$anon$5.transform(Typer.scala:2229)
        at dotty.tools.dotc.typer.Typer.caseRest$1(Typer.scala:2266)
        at dotty.tools.dotc.typer.Typer.typedCase(Typer.scala:2289)
        at dotty.tools.dotc.typer.Typer.typedCases$$anonfun$1(Typer.scala:2212)
        at dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99)
        at dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115)
        at dotty.tools.dotc.typer.Typer.typedCases(Typer.scala:2211)
        at dotty.tools.dotc.typer.Typer.$anonfun$39(Typer.scala:2194)
        at dotty.tools.dotc.typer.Applications.harmonic(Applications.scala:2662)
        at dotty.tools.dotc.typer.Applications.harmonic$(Applications.scala:465)
        at dotty.tools.dotc.typer.Typer.harmonic(Typer.scala:154)
        at dotty.tools.dotc.typer.Typer.typedMatchFinish(Typer.scala:2194)
        at dotty.tools.dotc.typer.Typer.typedMatch(Typer.scala:2122)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3588)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3658)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3851)
        at dotty.tools.dotc.typer.Typer.$anonfun$66(Typer.scala:2968)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2968)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3555)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3657)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3762)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3808)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3236)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3561)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3565)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3657)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3762)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3808)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3369)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3607)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3658)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3735)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3740)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3851)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:510)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:346)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1324)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:339)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:386)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:386)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.Run.showProgress(Run.scala:448)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:386)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:398)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:398)
        at dotty.tools.dotc.Run.compileSources(Run.scala:285)
        at dotty.tools.dotc.Run.compile(Run.scala:270)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
        at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:148)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:181)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:73)
        at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:72)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:181)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
        at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
        at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
        at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Note

Lib1.scala and Lib2.scala differ only in @ myAnnot with or without backticks

@prolativ
Copy link
Contributor Author

Possibly related to #22773

@prolativ
Copy link
Contributor Author

Possibly related to #22616 as well

@hamzaremmal hamzaremmal self-assigned this Mar 11, 2025
@prolativ
Copy link
Contributor Author

Workaround:

import scala.quoted.*

class myAnnot(value: String) extends scala.annotation.StaticAnnotation

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

def myAnnotValueImpl[A : Type](using Quotes): Expr[Option[String]] =
  import quotes.reflect.*
  TypeRepr.of[A] match
    case AnnotatedType(_, annot) =>
      annot.asExpr match
        case '{ new `myAnnot`($str) } =>
          '{ Some(${ str }) }
        case _ =>
          '{ None }
    case _ =>
      '{ None }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants