Skip to content

Commit 8bffc9e

Browse files
committed
Add regression test for i20309
1 parent 7f0d225 commit 8bffc9e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Diff for: tests/pos-macros/i20309/Macro_1.scala

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import scala.quoted.*
2+
import scala.compiletime.*
3+
4+
trait Context
5+
object Scope:
6+
def spawn[A](f: Context ?=> A): A = ???
7+
8+
type Contextual[T] = Context ?=> T
9+
10+
object Macros {
11+
inline def transformContextLambda[T](inline expr: Context ?=> T): Context => T =
12+
${ transformContextLambdaImpl[T]('expr) }
13+
14+
def transformContextLambdaImpl[T: Type](
15+
cexpr: Expr[Context ?=> T]
16+
)(using Quotes): Expr[Context => T] = {
17+
import quotes.reflect.*
18+
val tree = asTerm(cexpr)
19+
val traverse = new TreeMap() {}
20+
println(tree.show)
21+
traverse.transformTree(tree)(tree.symbol)
22+
'{ _ => ??? }
23+
}
24+
}

Diff for: tests/pos-macros/i20309/Test_2.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
transparent inline def inScope[T](inline expr: Context ?=> T): T =
3+
val fn = Macros.transformContextLambda[T](expr)
4+
fn(new Context {})
5+
6+
@main def Test = {
7+
inScope {
8+
Scope.spawn[Unit] { () }
9+
}
10+
}

0 commit comments

Comments
 (0)