-
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.
Merge pull request #13188 from dotty-staging/fix-#12948
Make body of quotes inlinable
- Loading branch information
Showing
7 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
Submodule Monocle
updated
1 files
+3 −3 | core/shared/src/main/scala-3.x/monocle/internal/focus/features/as/AsGenerator.scala |
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,9 @@ | ||
package mylib | ||
import scala.quoted.* | ||
|
||
object Main: | ||
protected def foo: Unit = {} | ||
inline def fooCaller: Unit = foo | ||
inline def fooCallerM: Unit = ${ fooMacro } | ||
def fooMacro(using Quotes): Expr[Unit] = | ||
'{ foo } |
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,5 @@ | ||
import mylib.Main | ||
|
||
object Test: | ||
Main.fooCaller | ||
Main.fooCallerM |
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,22 @@ | ||
package playground | ||
|
||
import scala.quoted._ | ||
|
||
object X { | ||
|
||
inline def power(n: Int, x: Double): Double = | ||
${ powerImpl('n, 'x) } | ||
|
||
private def powerImpl(nExpr: Expr[Int], xExpr: Expr[Double])(using Quotes): Expr[Double] = | ||
nExpr match { | ||
case Expr(n1) => '{ 42.0 } | ||
case _ => '{ dynamicPower($nExpr, $xExpr) } | ||
} | ||
|
||
private def dynamicPower(n: Int, x: Double): Double = { | ||
println(s"dynamic: $n^$x") | ||
if (n == 0) 1.0 | ||
else if (n % 2 == 0) dynamicPower(n / 2, x * x) | ||
else x * dynamicPower(n - 1, x) | ||
} | ||
} |
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,2 @@ | ||
import playground.X | ||
def test(x: Int) = X.power(x, 2) |