File tree 3 files changed +19
-2
lines changed
tests/run/quote-sep-comp-2
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -383,7 +383,7 @@ statically known exponent:
383
383
private def powerCode(n: Int, x: Expr[Double]): Expr[Double] =
384
384
if (n == 0) '(1.0)
385
385
else if (n == 1) x
386
- else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }
386
+ else if (n % 2 == 0) '{ val y = ~x * ~x; ~powerCode(n / 2, '(y)) }
387
387
else '{ ~x * ~powerCode(n - 1, x) }
388
388
389
389
The reference to ` n ` as an argument in ` ~powerCode(n, '(x)) ` is not
@@ -436,7 +436,8 @@ we currently impose the following restrictions on the use of splices.
436
436
1 . A top-level splice must appear in an inline function (turning that function
437
437
into a macro)
438
438
439
- 2 . The splice must call a previously compiled method.
439
+ 2 . The splice must call a previously compiled (previous to the call of the inline definition)
440
+ static method passing quoted arguments, constant arguments or inline arguments.
440
441
441
442
3 . Splices inside splices (but no intervening quotes) are not allowed.
442
443
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ object Macros {
4
+ def assertImpl (expr : Expr [Boolean ]) = ' { println(~ expr) }
5
+ }
Original file line number Diff line number Diff line change
1
+
2
+ object Test {
3
+
4
+ inline def assert2 (expr : => Boolean ): Unit = ~ Macros .assertImpl('(expr))
5
+
6
+ def main (args : Array [String ]): Unit = {
7
+ val x = 1
8
+ assert2(x != 0 )
9
+ assert2(x == 0 )
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments