-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give better feedback for classloader failure in staging
[Cherry-picked a34cd7d]
- Loading branch information
1 parent
e9f2ab0
commit fb8f8df
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import scala.quoted.* | ||
|
||
given staging.Compiler = | ||
staging.Compiler.make(getClass.getClassLoader) // warn: Suspicious top-level unqualified call to getClass | ||
|
||
class A(i: Int) | ||
|
||
def f(i: Expr[Int])(using Quotes): Expr[A] = { '{ new A($i) } } | ||
|
||
@main def Test = { | ||
try | ||
val g: Int => A = staging.run { '{ (i: Int) => ${ f('{i}) } } } | ||
println(g(3)) | ||
catch case ex: Exception => | ||
assert(ex.getMessage().startsWith("`scala.quoted.staging.run` failed to load a class.")) | ||
} |