Skip to content

Commit 0851b30

Browse files
committed
Fix rebase errors
1 parent b60d505 commit 0851b30

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@ trait TreeUtils {
99
import reflect._
1010

1111
/** Bind the `rhs` to a `val` and use it in `body` */
12-
def let(rhs: Term)(bodyType: Type)(body: Term.Ident => Term): Term = {
13-
// Recover all lost type information
12+
def let(rhs: Term)(body: Term.Ident => Term): Term = {
1413
type T // TODO probably it is better to use the Sealed contruct rather than let the user create their own existential type
15-
type U // TODO probably it is better to use the Sealed contruct rather than let the user create their own existential type
16-
implicit val bodyTpe: quoted.Type[U] = bodyType.seal.asInstanceOf[quoted.Type[U]]
1714
implicit val rhsTpe: quoted.Type[T] = rhs.tpe.seal.asInstanceOf[quoted.Type[T]]
1815
val rhsExpr = rhs.seal[T]
19-
20-
let[T, U](rhsExpr) { x =>
21-
val id = ('(x)).unseal.asInstanceOf[Term.Ident]
22-
id.withPos(rhs.pos)
23-
body(id).seal[U]
24-
}.unseal
25-
}
26-
27-
private def let[T: quoted.Type, U: quoted.Type](rhs: Expr[T])(in: Expr[T] => Expr[U]): Expr[U] = '{
28-
val x = ~rhs
29-
~in('(x))
16+
val expr = '{
17+
val x = ~rhsExpr
18+
~{
19+
val id = ('(x)).unseal.asInstanceOf[Term.Ident]
20+
body(id).seal[Any]
21+
}
22+
}
23+
expr.unseal
3024
}
3125
}

tests/run-with-compiler/reflect-select-copy/assert_1.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ object scalatest {
1515

1616
cond.unseal.underlyingArgument match {
1717
case Term.Apply(sel @ Term.Select(lhs, op), rhs :: Nil) =>
18-
let(lhs)(definitions.UnitType) { left =>
19-
let(rhs)(definitions.UnitType) { right =>
20-
let(Term.Apply(Term.Select.copy(sel)(left, op), right :: Nil))(definitions.UnitType) { result =>
18+
let(lhs) { left =>
19+
let(rhs) { right =>
20+
let(Term.Apply(Term.Select.copy(sel)(left, op), right :: Nil)) { result =>
2121
val l = left.seal[Any]
2222
val r = right.seal[Any]
2323
val b = result.seal[Boolean]
@@ -28,9 +28,9 @@ object scalatest {
2828
}.seal[Unit]
2929
case Term.Apply(f @ Term.Apply(Term.IsSelect(sel @ Term.Select(Term.Apply(qual, lhs :: Nil), op)), rhs :: Nil), implicits)
3030
if isImplicitMethodType(f.tpe) =>
31-
let(lhs)(definitions.UnitType) { left =>
32-
let(rhs)(definitions.UnitType) { right =>
33-
let(Term.Apply(Term.Apply(Term.Select.copy(sel)(Term.Apply(qual, left :: Nil), op), right :: Nil), implicits))(definitions.UnitType) { result =>
31+
let(lhs) { left =>
32+
let(rhs) { right =>
33+
let(Term.Apply(Term.Apply(Term.Select.copy(sel)(Term.Apply(qual, left :: Nil), op), right :: Nil), implicits)) { result =>
3434
val l = left.seal[Any]
3535
val r = right.seal[Any]
3636
val b = result.seal[Boolean]

tests/run-with-compiler/tasty-unsafe-let/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Macros {
1313
val rhsTerm = rhs.unseal
1414

1515
import reflect.util.{let => letTerm}
16-
letTerm(rhsTerm)(('[Unit]).unseal.tpe) { rhsId =>
16+
letTerm(rhsTerm) { rhsId =>
1717
body(rhsId.seal[Any].asInstanceOf[Expr[T]]).unseal // Dangerous uncheked cast!
1818
}.seal[Unit]
1919
}

0 commit comments

Comments
 (0)