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.
Update
staging.Compiler.make
documentation (scala#19428)
Fixes scala#19211 This addresses part of scala#19170, and scala#19176
- Loading branch information
Showing
8 changed files
with
85 additions
and
12 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
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,14 @@ | ||
import scala.quoted.* | ||
|
||
given staging.Compiler = | ||
object Dummy | ||
staging.Compiler.make(Dummy.getClass.getClassLoader) | ||
|
||
class A(i: Int) | ||
|
||
def f(i: Expr[Int])(using Quotes): Expr[A] = { '{ new A($i) } } | ||
|
||
@main def Test = { | ||
val g: Int => A = staging.run { '{ (i: Int) => ${ f('{i}) } } } | ||
println(g(3)) | ||
} |
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,10 @@ | ||
import scala.quoted.* | ||
|
||
given staging.Compiler = | ||
object Dummy | ||
staging.Compiler.make(Dummy.getClass.getClassLoader) | ||
|
||
class A | ||
val f: (A, Int) => Int = staging.run { '{ (q: A, x: Int) => x } } | ||
|
||
@main def Test = f(new A, 3) |