Skip to content

Commit f21504a

Browse files
authored
Merge pull request #10193 from dotty-staging/remove-quoted-util-var
Remove scala.quoted.util.Var from the library
2 parents fc8b512 + 3c19470 commit f21504a

File tree

2 files changed

+19
-50
lines changed

2 files changed

+19
-50
lines changed

library/src-bootstrapped/scala/quoted/util/Var.scala

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/run-staging/staged-streams_1.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,22 @@ object Test {
680680
println(run(test10()))
681681
}
682682
}
683+
684+
sealed trait Var[T] {
685+
def get(using qctx: QuoteContext): Expr[T]
686+
def update(e: Expr[T])(using qctx: QuoteContext): Expr[Unit]
687+
}
688+
689+
object Var {
690+
def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(using qctx: QuoteContext): Expr[U] = '{
691+
var x = $init
692+
${
693+
body(
694+
new Var[T] {
695+
def get(using qctx: QuoteContext): Expr[T] = 'x
696+
def update(e: Expr[T])(using qctx: QuoteContext): Expr[Unit] = '{ x = $e }
697+
}
698+
)
699+
}
700+
}
701+
}

0 commit comments

Comments
 (0)