scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.8k stars 1.04k forks source link

Scaladoc snippet compilation fails to evaluate a macro #21279

Open lbialy opened 1 month ago

lbialy commented 1 month ago

Compiler version

3.3.3

Minimized code

Quite hard to minimize. Problem shows up in scala-yaml repo and can be reproduced reliably by checking out the repo at commit 5bf61d1.

git clone git@github.com:VirtusLab/scala-yaml.git

cd scala-yaml

git fetch --all

git checkout 5bf61d1

sbt core/doc

# or

sbt core/publishLocal

Output

[error] -- Error: /home/runner/work/scala-yaml/scala-yaml/docs/_docs/examples.md:34:86 -
[error] 34 |case class Keys(key1: String, key2: Option[String], key3: Option[String]) derives YamlDecoder 
[error]    |                                                                                      ^
[error]    |Failed to evaluate macro.
[error]    |  Caused by class java.lang.ClassNotFoundException: org.virtuslab.yaml.DecoderMacros$
[error]    |    java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[error]    |    java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[error]    |    dotty.tools.dotc.quoted.Interpreter.loadClass(Interpreter.scala:212)
[error]    |    dotty.tools.dotc.quoted.Interpreter.loadModule(Interpreter.scala:197)
[error]    |    dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:165)
[error]    |    dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:80)
[error]    |    dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:258)
[error]    |    dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:99)

Expectation

Scaladoc can compile snippets that call macros.

lbialy commented 1 month ago

@jchyb