Closed
Description
Compiler version
3.3.0
Minimized code
Macro_1.scala
:
package defn
import scala.quoted.*
abstract class Macro {
def impl()(using Quotes): Expr[Int] = '{1}
}
Inline_2.scala
:
package user
import defn.Macro
object Inline extends Macro {
inline def callMacro(): Int =
${ this.impl() }
}
Test_2.scala
:
package user
object Test {
Inline.callMacro()
}
$ mkdir out1 out2
$ scalac Macro_1.scala -d out1
$ scalac -classpath out1 -d out2 Inline_2.scala Test_2.scala
-- Error: Test_2.scala:4:18 ----------------------------------------------------
4 | Inline.callMacro()
| ^^^^^^^^^^^^^^^^^^
|Failed to evaluate macro.
| Caused by class java.lang.ClassNotFoundException: user.Inline$
| java.lang.ClassLoader.loadClass(ClassLoader.java:418)
| java.lang.ClassLoader.loadClass(ClassLoader.java:351)
| dotty.tools.dotc.quoted.Interpreter.loadClass(Interpreter.scala:214)
| dotty.tools.dotc.quoted.Interpreter.loadModule(Interpreter.scala:199)
| dotty.tools.dotc.quoted.Interpreter.liftedTree1$1(Interpreter.scala:165)
| dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:170)
| dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:85)
| dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:247)
| dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:95)
|
1 error found
Weirdly enough, if the package where the inline definition is present exists on the classpath, then it works:
$ mkdir out1/user
$ scalac -classpath out1 -d out2 Inline_2.scala Test_2.scala
$
Expectation
Successful compilation.