Skip to content

Commit c28f8b3

Browse files
Merge pull request #6689 from dotty-staging/homogenize-run-and-splice
Homogenize $ and run notation
2 parents ea37f3f + 9e3fdb9 commit c28f8b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+124
-88
lines changed

compiler/test-resources/repl-macros/i6007

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ scala> val v = '{ (if true then Some(1) else None).map(v => v+1) }
44
val v: quoted.Expr[Option[Int]] = Expr(<pickled tasty>)
55
scala> v.show
66
val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1)))
7-
scala> v.run
7+
scala> scala.quoted.run(v)
88
val res1: Option[Int] = Some(2)

library/src-2.x/scala/quoted/Expr.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package quoted {
88
*
99
* May throw a FreeVariableError on expressions that came from a macro.
1010
*/
11+
@deprecated("Use scala.quoted.run", "")
1112
final def run(implicit toolbox: Toolbox): T = toolbox.run(this)
1213

1314
}

library/src-3.x/scala/quoted/Expr.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package quoted {
88
*
99
* May throw a FreeVariableError on expressions that came from a macro.
1010
*/
11+
@deprecated("Use scala.quoted.run", "")
1112
final def run(implicit toolbox: Toolbox): T = toolbox.run(this)
1213

1314
}

library/src-3.x/scala/quoted/package.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ package scala
22

33
package object quoted {
44

5+
/** Evaluate the contents of this expression and return the result.
6+
*
7+
* Usage:
8+
* ```
9+
* val e: T = run {
10+
* expr
11+
* }
12+
* ```
13+
* where `expr: Expr[T]`
14+
*
15+
* May throw a FreeVariableError on expressions that came from a macro.
16+
*/
17+
def run[T](expr: Expr[T]) given (toolbox: Toolbox): T = toolbox.run(expr)
18+
519
object autolift {
620
implicit def autoToExpr[T: Liftable](x: T): Expr[T] = x.toExpr
721
}

tests/run-with-compiler-custom-args/staged-streams_1.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,25 +678,25 @@ object Test {
678678

679679
def main(args: Array[String]): Unit = {
680680
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
681-
println(test1().run)
681+
println(run(test1()))
682682
println
683-
println(test2().run)
683+
println(run(test2()))
684684
println
685-
println(test3().run)
685+
println(run(test3()))
686686
println
687-
println(test4().run)
687+
println(run(test4()))
688688
println
689-
println(test5().run)
689+
println(run(test5()))
690690
println
691-
println(test6().run)
691+
println(run(test6()))
692692
println
693-
println(test7().run)
693+
println(run(test7()))
694694
println
695-
println(test8().run)
695+
println(run(test8()))
696696
println
697-
println(test9().run)
697+
println(run(test9()))
698698
println
699-
println(test10().run)
699+
println(run(test10()))
700700
}
701701
}
702702

tests/run-with-compiler/i3876-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
def f(x: Int): Int = x + x
1010
f
1111
}
12-
println(f2(x).run)
12+
println(run(f2(x)))
1313
println(f2(x).show)
1414
}
1515
}

tests/run-with-compiler/i3876-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
val f: (x: Int) => Int = x => x + x
1010
f
1111
}
12-
println(f3(x).run)
12+
println(run(f3(x)))
1313
println(f3(x).show) // TODO improve printer
1414
}
1515
}

tests/run-with-compiler/i3876-d.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Test {
88
val f4: Expr[Int => Int] = '{
99
inlineLambda
1010
}
11-
println(f4(x).run)
11+
println(run(f4(x)))
1212
println(f4(x).show)
1313
}
1414

tests/run-with-compiler/i3876-e.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Test {
88
val f4: Expr[Int => Int] = '{
99
inlineLambda
1010
}
11-
println(f4(x).run)
11+
println(run(f4(x)))
1212
println(f4(x).show)
1313
}
1414

tests/run-with-compiler/i3876.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Test {
66
val x: Expr[Int] = '{3}
77

88
val f: Expr[Int => Int] = '{ (x: Int) => x + x }
9-
println(f(x).run)
9+
println(run(f(x)))
1010
println(f(x).show)
1111
}
1212
}

0 commit comments

Comments
 (0)