Skip to content

Commit 8267496

Browse files
committed
Avoid uses of quoted.Expr[_]
These may end up requiering a `quoted.Type[_]` which cannot be provided.
1 parent 7a17422 commit 8267496

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

docs/blog/_posts/2019-08-30-18th-dotty-milestone-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ For precise rules, semantics and a larger example of `BigFloat`, see [the docume
256256
## Metaprogramming Progress
257257
We are making steady progress with the language metaprogramming features. The metaprogramming spotlights of this release are as follows:
258258

259-
- `toExprOfTuple` method which allows converting a `Seq[Expr[_]]` to `Expr[Tuple]`. The types of the expressions will be preserved in the tuple. See [#7037](https://github.com/lampepfl/dotty/pull/7037) and [#7076](https://github.com/lampepfl/dotty/pull/7076) for the details.
259+
- `toExprOfTuple` method which allows converting a `Seq[Expr[Any]]` to `Expr[Tuple]`. The types of the expressions will be preserved in the tuple. See [#7037](https://github.com/lampepfl/dotty/pull/7037) and [#7076](https://github.com/lampepfl/dotty/pull/7076) for the details.
260260
- `toExprOfTuple` method that converts a tuple of expressions to an expression of tuple – see [#7047](https://github.com/lampepfl/dotty/pull/7047).
261261
- `toExprOfSeq` which converts an `Seq[Expr[A]]` to `Expr[Seq[A]]` – see [#6935](https://github.com/lampepfl/dotty/pull/6935).
262262
- More `Liftable` instances – for Tuples of arity greater than 22, `BigInt` and `BigDecimal` – see [#6947](https://github.com/lampepfl/dotty/pull/6947) and [#6944](https://github.com/lampepfl/dotty/pull/6944).

docs/docs/reference/metaprogramming/macros-spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ through quotes. Most likely, those constructors would work over `Expr`
211211
types which lack a known type argument. For instance, an `Apply`
212212
constructor could be typed as follows:
213213
```scala
214-
def Apply(fn: Expr[_], args: List[Expr[_]]): Expr[_]
214+
def Apply(fn: Expr[Any], args: List[Expr[Any]]): Expr[Any]
215215
```
216216
This would allow constructing applications from lists of arguments
217217
without having to match the arguments one-by-one with the
218218
corresponding formal parameter types of the function. We then need "at
219-
the end" a method to convert an `Expr[_]` to an `Expr[T]` where `T` is
220-
given from the outside. E.g. if `code` yields a `Expr[_]`, then
219+
the end" a method to convert an `Expr[Any]` to an `Expr[T]` where `T` is
220+
given from the outside. E.g. if `code` yields a `Expr[Any]`, then
221221
`code.atType[T]` yields an `Expr[T]`. The `atType` method has to be
222222
implemented as a primitive; it would check that the computed type
223223
structure of `Expr` is a subtype of the type structure representing

docs/docs/reference/other-new-features/quoted-pattern-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def foo(x: Expr[Int])(using tasty.Reflect): Expr[Int] = x match {
3232
At runtime to a `quoted.Expr` can be matched to another using `scala.internal.quoted.Expr.unapply`.
3333

3434
```scala
35-
def unapply[Tup <: Tuple](scrutineeExpr: Expr[_])(implicit patternExpr: Expr[_], reflection: Reflection): Option[Tup]
35+
def unapply[Tup <: Tuple](scrutineeExpr: Expr[Any])(implicit patternExpr: Expr[Any], reflection: Reflection): Option[Tup]
3636
```
3737

3838
The `scrutineeExpr` is a normal quoted expression while `patternExpr` may contain holes representing splices.

library/src/scala/internal/quoted/Expr.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ object Expr {
2626
* - scala.internal.Quoted.patternHole[T]: hole that matches an expression `x` of type `Expr[U]`
2727
* if `U <:< T` and returns `x` as part of the match.
2828
*
29-
* @param scrutineeExpr `Expr[_]` on which we are pattern matching
30-
* @param patternExpr `Expr[_]` containing the pattern tree
29+
* @param scrutineeExpr `Expr[Any]` on which we are pattern matching
30+
* @param patternExpr `Expr[Any]` containing the pattern tree
3131
* @param hasTypeSplices `Boolean` notify if the pattern has type splices (if so we use a GADT context)
3232
* @param qctx the current QuoteContext
3333
* @return None if it did not match, `Some(tup)` if it matched where `tup` contains `Expr[Ti]``
3434
*/
35-
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[_])(using patternExpr: scala.quoted.Expr[_],
35+
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[Any])(using patternExpr: scala.quoted.Expr[Any],
3636
hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = {
3737
new Matcher.QuoteMatcher[qctx.type].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
3838
}

library/src/scala/quoted/Expr.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ object Expr {
8080
* ```
8181
*/
8282
def betaReduce[F, Args <: Tuple, R, G](f: Expr[F])(using tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G =
83-
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
83+
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[Any]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
8484

8585
/** `Expr.betaReduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(using $x1, ..., $xn)}`, however it optimizes this call
8686
* by returning the result of beta-reducing `f(using x1, ..., xn)` if `f` is a known lambda expression.
@@ -91,7 +91,7 @@ object Expr {
9191
* ```
9292
*/
9393
def betaReduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(using tf: TupledFunction[F, Args ?=> R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G =
94-
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
94+
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[Any]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
9595

9696
/** Returns a null expresssion equivalent to `'{null}` */
9797
def nullExpr: QuoteContext ?=> Expr[Null] = qctx ?=> {
@@ -109,7 +109,7 @@ object Expr {
109109
* Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression
110110
* will be equivalent to `'{ $s1; $s2; ...; $e }`.
111111
*/
112-
def block[T](statements: List[Expr[_]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
112+
def block[T](statements: List[Expr[Any]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
113113
import qctx.tasty._
114114
Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]]
115115
}
@@ -140,11 +140,11 @@ object Expr {
140140
/** Lifts this sequence of expressions into an expression of a tuple
141141
*
142142
* Transforms a sequence of expression
143-
* `Seq(e1, e2, ...)` where `ei: Expr[_]`
143+
* `Seq(e1, e2, ...)` where `ei: Expr[Any]`
144144
* to an expression equivalent to
145145
* `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]`
146146
*/
147-
def ofTuple(seq: Seq[Expr[_]])(using qctx: QuoteContext): Expr[Tuple] = {
147+
def ofTuple(seq: Seq[Expr[Any]])(using qctx: QuoteContext): Expr[Tuple] = {
148148
seq match {
149149
case Seq() =>
150150
unitExpr
@@ -199,7 +199,7 @@ object Expr {
199199

200200
/** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
201201
def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T)(using qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = {
202-
val elems: Seq[Expr[_]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[_]]]
202+
val elems: Seq[Expr[Any]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[Any]]]
203203
ofTuple(elems).cast[Tuple.InverseMap[T, Expr]]
204204
}
205205

library/src/scala/quoted/QuoteContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QuoteContext(val tasty: scala.tasty.Reflection) { self =>
5353
tasty.warning(msg, tasty.rootPosition)
5454

5555
/** Report a warning at the on the position of `expr` */
56-
def warning(msg: => String, expr: Expr[_]): Unit =
56+
def warning(msg: => String, expr: Expr[Any]): Unit =
5757
tasty.warning(msg, expr.unseal(using this).pos)
5858

5959
}

library/src/scala/tasty/reflect/CompilerInterface.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ trait CompilerInterface {
125125
/** Unpickle `repr` which represents a pickled `Expr` tree,
126126
* replacing splice nodes with `args`
127127
*/
128-
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Expr[_]
128+
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledArgs): scala.quoted.Expr[Any]
129129

130130
/** Unpickle `repr` which represents a pickled `Type` tree,
131131
* replacing splice nodes with `args`
@@ -1425,11 +1425,11 @@ trait CompilerInterface {
14251425
// QUOTED SEAL/UNSEAL //
14261426
////////////////////////
14271427

1428-
/** View this expression `quoted.Expr[_]` as a `Term` */
1429-
def QuotedExpr_unseal(self: scala.quoted.Expr[_])(using ctx: Context): Term
1428+
/** View this expression `quoted.Expr[Any]` as a `Term` */
1429+
def QuotedExpr_unseal(self: scala.quoted.Expr[Any])(using ctx: Context): Term
14301430

14311431
/** Checked cast to a `quoted.Expr[U]` */
1432-
def QuotedExpr_cast[U](self: scala.quoted.Expr[_])(using tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U]
1432+
def QuotedExpr_cast[U](self: scala.quoted.Expr[Any])(using tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U]
14331433

14341434
/** View this expression `quoted.Type[T]` as a `TypeTree` */
14351435
def QuotedType_unseal(self: scala.quoted.Type[_])(using ctx: Context): TypeTree

0 commit comments

Comments
 (0)