forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve incorrect classloader reporting in staging
* do not println staging crashes to stdout * enrich the errors coming from the compiler with additional hints about using the correct classloader
- Loading branch information
Showing
7 changed files
with
52 additions
and
2 deletions.
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
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 @@ | ||
exception thrown, no additional printlns |
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.getParent) // different classloader that 19170b.scala | ||
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("An unhandled exception was thrown in the staging compiler."), ex.getMessage()) | ||
println("exception thrown, no additional printlns") | ||
} |
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 @@ | ||
exception thrown, no additional printlns |
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,14 @@ | ||
import scala.quoted.* | ||
|
||
given staging.Compiler = | ||
staging.Compiler.make(getClass.getClassLoader.getParent) // we want to make sure the classloader is incorrect | ||
|
||
class A | ||
|
||
@main def Test = | ||
try | ||
val f: (A, Int) => Int = staging.run { '{ (q: A, x: Int) => x } } | ||
f(new A, 3) | ||
catch case ex: Exception => | ||
assert(ex.getMessage().startsWith("An unhandled exception was thrown in the staging compiler."), ex.getMessage()) | ||
println("exception thrown, no additional printlns") |