-
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
- Loading branch information
1 parent
a0a8f0e
commit 78f9328
Showing
3 changed files
with
41 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.")) | ||
} |
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,12 @@ | ||
import scala.quoted.* | ||
|
||
given staging.Compiler = | ||
staging.Compiler.make(getClass.getClassLoader) // warn: Suspicious top-level unqualified call to getClass | ||
|
||
class A | ||
val f: (A, Int) => Int = staging.run { '{ (q: A, x: Int) => x } } | ||
|
||
@main def Test = | ||
try f(new A, 3) | ||
catch case ex: Exception => | ||
assert(ex.getMessage().startsWith("`scala.quoted.staging.run` failed to load a class.")) |