Skip to content

Commit 6414e3f

Browse files
Merge pull request #9078 from dotty-staging/avoid-overloading-of-Expr-ofTuple
Avoid overloading of Expr.ofTuple
2 parents 2c01512 + aed8298 commit 6414e3f

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ object Expr {
128128
* to an expression equivalent to
129129
* `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]`
130130
*/
131-
def ofTuple(seq: Seq[Expr[Any]])(using qctx: QuoteContext): Expr[Tuple] = {
131+
def ofTupleFromSeq(seq: Seq[Expr[Any]])(using qctx: QuoteContext): Expr[Tuple] = {
132132
seq match {
133133
case Seq() =>
134134
'{ Tuple() }
@@ -184,7 +184,7 @@ object Expr {
184184
/** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
185185
def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T)(using qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = {
186186
val elems: Seq[Expr[Any]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[Any]]]
187-
ofTuple(elems).cast[Tuple.InverseMap[T, Expr]]
187+
ofTupleFromSeq(elems).cast[Tuple.InverseMap[T, Expr]]
188188
}
189189

190190
/** Find an implicit of type `T` in the current scope given by `qctx`.

tests/run-macros/quote-toExprOfTuple/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Macro {
88
import util._
99

1010
val seq = List(t0, t1)
11-
val res = Expr.ofTuple(seq)
11+
val res = Expr.ofTupleFromSeq(seq)
1212
res.cast[(T0, T1)]
1313
}
1414
}

tests/run-macros/refined-selectable-macro/Macro_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ object Macro {
3636
def tupleElem(name: String, info: Type): Expr[Any] = {
3737
val nameExpr = Expr(name)
3838
info.seal match { case '[$qType] =>
39-
Expr.ofTuple(Seq(nameExpr, '{ $s.selectDynamic($nameExpr).asInstanceOf[$qType] }))
39+
Expr.ofTupleFromSeq(Seq(nameExpr, '{ $s.selectDynamic($nameExpr).asInstanceOf[$qType] }))
4040
}
4141
}
4242

4343
val ret = rec(repr).reverse.map(e => tupleElem(e._1, e._2))
4444

45-
Expr.ofTuple(ret)
45+
Expr.ofTupleFromSeq(ret)
4646
}
4747

4848
private def fromTupleImpl[T: Type](s: Expr[Tuple], newRecord: Expr[Array[(String, Any)] => T])(using qctx:QuoteContext) : Expr[Any] = {

tests/run-staging/quote-toExprOfTuple.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Test {
77
def main(args: Array[String]): Unit = {
88
for (n <- 0 to 25) {
99
prev = 0
10-
println(run { Expr.ofTuple(Seq.fill(n)('{next})) })
10+
println(run { Expr.ofTupleFromSeq(Seq.fill(n)('{next})) })
1111
}
1212
}
1313
var prev = 0

0 commit comments

Comments
 (0)