With Scal 3 macros the following works for any value provided. When I compile I get the output The symbol is object <whatever value I give>
.
//..inside a macro function
val symbol = Symbol.requiredPackage("alsdkfjsdlkfj") //Works for any random value here
println(s"The symbol is $symbol") //This prints "The symbol is object alsdkfjsdlkfj"
But such a package does not exist. Shouldn’t this give a compilation error? The doc for requiredPackage
method says Get package symbol if package is either defined in current compilation run or present on classpath.
I am assuming that if the package is not defined in current compilation run or present on classpath it should fail.
Edit
I am trying out Scala 3 macros from this project. The linked page contains the complete source code. Search for the line val symbol = Symbol.requiredPackage(packageName)
in object PackageSearch