Skip to content

Commit 2e220d5

Browse files
Merge pull request #10165 from dotty-staging/remove-deprecated-tasty-member
Remove deprecated `tasty` member
2 parents 5e8c13f + 1efb039 commit 2e220d5

File tree

26 files changed

+47
-56
lines changed

26 files changed

+47
-56
lines changed
Submodule dotty-cps-async updated 34 files

library/src-bootstrapped/scala/quoted/QuoteContext.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ trait QuoteContext { self =>
1717
*/
1818
val reflect: scala.tasty.Reflection
1919

20-
@deprecated("Use `reflect` instead", "")
21-
def tasty: reflect.type = reflect
22-
2320
/** Type of a QuoteContext provided by a splice within a quote that took this context.
2421
* It is only required if working with the reflection API.
2522
*
@@ -34,7 +31,7 @@ trait QuoteContext { self =>
3431
* ```
3532
*/
3633
type Nested = QuoteContext {
37-
val reflect: self.tasty.type
34+
val reflect: self.reflect.type
3835
}
3936

4037
}

library/src-non-bootstrapped/scala/quoted/QuoteContext.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package scala.quoted
33
trait QuoteContext { self =>
44

55
val reflect: scala.tasty.Reflection
6-
def tasty: reflect.type = reflect
76

87
type Nested = QuoteContext {
9-
val tasty: self.tasty.type
8+
val reflect: self.reflect.type
109
}
1110

1211
}

sbt-dotty/sbt-test/source-dependencies/macro-expansion-dependencies-1/changes/MacroCompileError.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macro {
55
inline def f(): Unit = ${ macroImplementation }
66

77
def macroImplementation(using qctx: QuoteContext): Expr[Unit] = {
8-
import qctx.tasty._
8+
import qctx.reflect._
99
error("some error", rootPosition)
1010
'{ println("Implementation in MacroCompileError") }
1111
}

sbt-dotty/sbt-test/source-dependencies/macro-expansion-dependencies-2/changes/MacroRuntimeCompileError.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
object MacroRuntime {
44

55
def impl()(using qctx: QuoteContext): Expr[Unit] = {
6-
import qctx.tasty._
6+
import qctx.reflect._
77
error("some error", rootPosition)
88
'{ println("Implementation in MacroCompileError") }
99
}

scala3doc/dotty-docs/docs/docs/reference/contextual/derivation-macro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ from the signature. The body of the `derived` method is shown below:
4242

4343
```scala
4444
given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
45-
import qctx.tasty._
45+
import qctx.reflect._
4646

4747
val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
4848

@@ -177,7 +177,7 @@ object Eq {
177177
}
178178

179179
given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
180-
import qctx.tasty._
180+
import qctx.reflect._
181181

182182
val ev: Expr[Mirror.Of[T]] = Expr.summon(using '[Mirror.Of[T]]).get
183183

scala3doc/dotty-docs/docs/docs/reference/metaprogramming/tasty-reflect.md

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
---
22
layout: doc-page
3-
title: "TASTy Reflect"
3+
title: "Quoted Reflect"
44
---
55

6-
TASTy Reflect enables inspection and construction of Typed Abstract Syntax Trees
6+
Reflection enables inspection and construction of Typed Abstract Syntax Trees
77
(Typed-AST). It may be used on quoted expressions (`quoted.Expr`) and quoted
88
types (`quoted.Type`) from [Macros](./macros.md) or on full TASTy files.
99

1010
If you are writing macros, please first read [Macros](./macros.md).
11-
You may find all you need without using TASTy Reflect.
11+
You may find all you need without using reflection.
1212

1313

14-
## API: From quotes and splices to TASTy reflect trees and back
14+
## API: From quotes and splices to reflect trees and back
1515

1616
With `quoted.Expr` and `quoted.Type` we can compute code but also analyze code
1717
by inspecting the ASTs. [Macros](./macros.md) provide the guarantee that the
18-
generation of code will be type-correct. Using TASTy Reflect will break these
18+
generation of code will be type-correct. Using reflect will break these
1919
guarantees and may fail at macro expansion time, hence additional explicit
2020
checks must be done.
2121

2222
To provide reflection capabilities in macros we need to add an implicit
23-
parameter of type `scala.quoted.QuoteContext` and import `tasty._` from it in
23+
parameter of type `scala.quoted.QuoteContext` and import `reflect._` from it in
2424
the scope where it is used.
2525

2626
```scala
@@ -29,19 +29,19 @@ import scala.quoted._
2929
inline def natConst(x: => Int): Int = ${natConstImpl('{x})}
3030

3131
def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = {
32-
import qctx.tasty._
32+
import qctx.reflect._
3333
...
3434
}
3535
```
3636

3737
### Extractors
3838

39-
`import qctx.tasty._` will provide all extractors and methods on TASTy Reflect
39+
`import qctx.reflect._` will provide all extractors and methods on reflect
4040
trees. For example the `Literal(_)` extractor used below.
4141

4242
```scala
4343
def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = {
44-
import qctx.tasty._
44+
import qctx.reflect._
4545
val xTree: Term = x.unseal
4646
xTree match {
4747
case Inlined(_, _, Literal(Constant(n: Int))) =>
@@ -59,9 +59,9 @@ def natConstImpl(x: Expr[Int])(using qctx: QuoteContext): Expr[Int] = {
5959
```
6060

6161
To easily know which extractors are needed, the `showExtractors` method on a
62-
`qctx.tasty.Term` returns the string representation of the extractors.
62+
`qctx.reflect.Term` returns the string representation of the extractors.
6363

64-
The method `qctx.tasty.Term.seal` provides a way to go back to a
64+
The method `qctx.reflect.Term.seal` provides a way to go back to a
6565
`quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type
6666
must be set explicitly with a checked `cast` call. If the type does not conform
6767
to it an exception will be thrown at runtime.
@@ -77,7 +77,7 @@ operation expression passed while calling the `macro` below.
7777
inline def macro(param: => Boolean): Unit = ${ macroImpl('param) }
7878

7979
def macroImpl(param: Expr[Boolean])(using qctx: QuoteContext): Expr[Unit] = {
80-
import qctx.tasty._
80+
import qctx.reflect._
8181
import util._
8282

8383
param.unseal.underlyingArgument match {
@@ -99,7 +99,7 @@ point.
9999

100100
```scala
101101
def macroImpl()(qctx: QuoteContext): Expr[Unit] = {
102-
import qctx.tasty._
102+
import qctx.reflect._
103103
val pos = rootPosition
104104

105105
val path = pos.sourceFile.jpath.toString
@@ -136,7 +136,7 @@ def collectPatternVariables(tree: Tree)(implicit ctx: Context): List[Symbol] = {
136136
```
137137

138138
A `TreeTraverser` extends a `TreeAccumulator` and performs the same traversal
139-
but without returning any value. Finally a `TreeMap` performs a transformation.
139+
but without returning any value. Finally, a `TreeMap` performs a transformation.
140140

141141
#### Let
142142

@@ -150,8 +150,3 @@ def let(rhs: Term)(body: Ident => Term): Term = ...
150150

151151
def lets(terms: List[Term])(body: List[Term] => Term): Term = ...
152152
```
153-
154-
## More Examples
155-
156-
* Start experimenting with TASTy Reflect ([link](https://github.com/nicolasstucki/tasty-reflection-exercise))
157-

scala3doc/src/dotty/dokka/tasty/TastyParser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ case class SbtDokkaTastyInspector(
8888

8989
override def run(implicit ctx: Context): Unit =
9090
val qctx = QuoteContextImpl()
91-
self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.tasty.Tree])
91+
self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.reflect.Tree])
9292

9393
end TastyInspectorPhase
9494

tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait TastyInspector:
1818
self =>
1919

2020
/** Process a TASTy file using TASTy reflect */
21-
protected def processCompilationUnit(using QuoteContext)(root: qctx.tasty.Tree): Unit
21+
protected def processCompilationUnit(using QuoteContext)(root: qctx.reflect.Tree): Unit
2222

2323
/** Load and process TASTy files using TASTy reflect
2424
*
@@ -85,7 +85,7 @@ trait TastyInspector:
8585

8686
override def run(implicit ctx: Context): Unit =
8787
val qctx = QuoteContextImpl()
88-
self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.tasty.Tree])
88+
self.processCompilationUnit(using qctx)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.reflect.Tree])
8989

9090
end TastyInspectorPhase
9191

tests/neg-macros/i6976/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object macros {
66
inline def mcr(x: => Any) = ${mcrImpl('x)}
77

88
def mcrImpl(body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = {
9-
import ctx.tasty._
9+
import ctx.reflect._
1010
body.unseal match { case Block(_, _) => '{2} }
1111
}
1212
}

tests/pos-macros/i7011/Macros_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import scala.quoted._
22

33
inline def mcr(body: => Any): Unit = ${mcrImpl('body)}
44

5-
def mcrImpl[T](body: Expr[Any])(using ctx: QuoteContext) : Expr[Any] = {
6-
import ctx.tasty.{_, given}
5+
def mcrImpl[T](body: Expr[Any])(using QuoteContext) : Expr[Any] = {
6+
import qctx.reflect._
77

88
val bTree = body.unseal
99
val under = bTree.underlyingArgument

tests/pos-macros/i7030/Macros_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def innerImpl(exprs: Expr[Any])(using QuoteContext): Expr[Any] =
55
'{$exprs ; ()}
66

77
inline def outer(expr: => Any): Any = ${outerImpl('expr)}
8-
def outerImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = {
9-
import ctx.tasty._
8+
def outerImpl(body: Expr[Any])(using QuoteContext): Expr[Any] = {
9+
import qctx.reflect._
1010
body.unseal.underlyingArgument.seal
1111
}

tests/pos-macros/i8651b.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ object Macros {
88

99
inline def coroutine[T](inline body: Any): Coroutine[T] = ${ coroutineImpl('{body}) }
1010

11-
def coroutineImpl[T: Type](expr: Expr[_ <: Any])(implicit qtx: QuoteContext): Expr[Coroutine[T]] = {
12-
import qtx.tasty.{_, given}
11+
def coroutineImpl[T: Type](expr: Expr[_ <: Any])(using QuoteContext): Expr[Coroutine[T]] = {
12+
import qctx.reflect._
1313

1414
'{
1515
new Coroutine[T] {

tests/pos-macros/i9240/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inline def diveInto[T]: String = ${ diveIntoImpl[T]() }
55

66
def diveIntoImpl[T]()(implicit qctx: QuoteContext, ttype: Type[T]): Expr[String] =
77
import qctx.reflect._
8-
Expr( unwindType(qctx.tasty)(TypeRepr.of[T]) )
8+
Expr( unwindType(qctx.reflect)(TypeRepr.of[T]) )
99

1010
def unwindType(reflect: Reflection)(aType: reflect.TypeRepr): String =
1111
import reflect._
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
22

33
inline def mcr(x: => Unit): Unit = ${mcrImpl('x)}
4-
def mcrImpl(x: Expr[Unit])(using ctx: QuoteContext) : Expr[Unit] =
5-
import ctx.tasty._
4+
def mcrImpl(x: Expr[Unit])(using QuoteContext) : Expr[Unit] =
5+
import qctx.reflect._
66
val tr: Term = x.unseal
77
object m extends TreeMap
88
m.transformTerm(tr).seal.cast[Unit]

tests/run-macros/i7008/macro_1.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def mcrProxy(expr: Expr[Boolean])(using QuoteContext): Expr[Unit] = {
1010
res
1111
}
1212

13-
def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(using ctx: QuoteContext, tt: Type[T]): Expr[Unit] = {
14-
import ctx.tasty._
13+
def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(using QuoteContext, Type[T]): Expr[Unit] = {
14+
import qctx.reflect._
1515
val arg = Varargs(Seq('{(Box($expr))}))
1616
Expr.betaReduce('{$func($arg)})
17-
}
17+
}

tests/run-staging/i6992/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object macros {
1010
class Foo { val x = 10 }
1111

1212
def mcrImpl(body: Expr[Any])(using ctx: QuoteContext): Expr[Any] = {
13-
import ctx.tasty._
13+
import ctx.reflect._
1414
try {
1515
body match {
1616
case '{$x: Foo} => Expr(run(x).x)

0 commit comments

Comments
 (0)