Skip to content

Commit 3854228

Browse files
committed
Remove unnecessary imports
1 parent aa0c87b commit 3854228

File tree

5 files changed

+29
-59
lines changed

5 files changed

+29
-59
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ object Expr {
3434
*/
3535
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[_])(using patternExpr: scala.quoted.Expr[_],
3636
hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = {
37-
import qctx.tasty._
3837
new Matcher.QuoteMatcher[qctx.type].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
3938
}
4039

library/src/scala/internal/quoted/Type.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ object Type {
2626
*/
2727
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: scala.quoted.Type[_])(using patternType: scala.quoted.Type[_],
2828
hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = {
29-
import qctx.tasty._
3029
new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
3130
}
3231

library/src/scala/quoted/Expr.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ object Expr {
6060
* Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
6161
* ```
6262
*/
63-
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 = {
64-
import qctx.tasty._
63+
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 =
6564
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
66-
}
6765

6866
/** `Expr.betaReduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(using $x1, ..., $xn)}`, however it optimizes this call
6967
* by returning the result of beta-reducing `f(using x1, ..., xn)` if `f` is a known lambda expression.
@@ -73,10 +71,8 @@ object Expr {
7371
* Expr.betaReduceGiven(_): Expr[(T1, ..., Tn) ?=> R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
7472
* ```
7573
*/
76-
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 = {
77-
import qctx.tasty._
74+
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 =
7875
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
79-
}
8076

8177
/** Returns a null expresssion equivalent to `'{null}` */
8278
def nullExpr: QuoteContext ?=> Expr[Null] = qctx ?=> {
@@ -184,7 +180,6 @@ object Expr {
184180

185181
/** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
186182
def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T)(using qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = {
187-
import qctx.tasty._
188183
val elems: Seq[Expr[_]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[_]]]
189184
ofTuple(elems).cast[Tuple.InverseMap[T, Expr]]
190185
}

library/src/scala/quoted/Type.scala

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,31 @@ class Type[T <: AnyKind] private[scala] {
2121
/** Some basic type tags, currently incomplete */
2222
object Type {
2323

24-
given UnitTag(using qctx: QuoteContext) as Type[Unit] = {
25-
import qctx.tasty._
26-
defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]]
27-
}
28-
29-
given BooleanTag(using qctx: QuoteContext) as Type[Boolean] = {
30-
import qctx.tasty._
31-
defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]]
32-
}
33-
34-
given ByteTag(using qctx: QuoteContext) as Type[Byte] = {
35-
import qctx.tasty._
36-
defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]]
37-
}
38-
39-
given CharTag(using qctx: QuoteContext) as Type[Char] = {
40-
import qctx.tasty._
41-
defn.CharType.seal.asInstanceOf[quoted.Type[Char]]
42-
}
43-
44-
given ShortTag(using qctx: QuoteContext) as Type[Short] = {
45-
import qctx.tasty._
46-
defn.ShortType.seal.asInstanceOf[quoted.Type[Short]]
47-
}
48-
49-
given IntTag(using qctx: QuoteContext) as Type[Int] = {
50-
import qctx.tasty._
51-
defn.IntType.seal.asInstanceOf[quoted.Type[Int]]
52-
}
53-
54-
given LongTag(using qctx: QuoteContext) as Type[Long] = {
55-
import qctx.tasty._
56-
defn.LongType.seal.asInstanceOf[quoted.Type[Long]]
57-
}
58-
59-
given FloatTag(using qctx: QuoteContext) as Type[Float] = {
60-
import qctx.tasty._
61-
defn.FloatType.seal.asInstanceOf[quoted.Type[Float]]
62-
}
63-
64-
given DoubleTag(using qctx: QuoteContext) as Type[Double] = {
65-
import qctx.tasty._
66-
defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]]
67-
}
24+
given UnitTag(using qctx: QuoteContext) as Type[Unit] =
25+
qctx.tasty.defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]]
26+
27+
given BooleanTag(using qctx: QuoteContext) as Type[Boolean] =
28+
qctx.tasty.defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]]
29+
30+
given ByteTag(using qctx: QuoteContext) as Type[Byte] =
31+
qctx.tasty.defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]]
32+
33+
given CharTag(using qctx: QuoteContext) as Type[Char] =
34+
qctx.tasty.defn.CharType.seal.asInstanceOf[quoted.Type[Char]]
35+
36+
given ShortTag(using qctx: QuoteContext) as Type[Short] =
37+
qctx.tasty.defn.ShortType.seal.asInstanceOf[quoted.Type[Short]]
38+
39+
given IntTag(using qctx: QuoteContext) as Type[Int] =
40+
qctx.tasty.defn.IntType.seal.asInstanceOf[quoted.Type[Int]]
41+
42+
given LongTag(using qctx: QuoteContext) as Type[Long] =
43+
qctx.tasty.defn.LongType.seal.asInstanceOf[quoted.Type[Long]]
44+
45+
given FloatTag(using qctx: QuoteContext) as Type[Float] =
46+
qctx.tasty.defn.FloatType.seal.asInstanceOf[quoted.Type[Float]]
47+
48+
given DoubleTag(using qctx: QuoteContext) as Type[Double] =
49+
qctx.tasty.defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]]
6850

6951
}

library/src/scala/quoted/unsafe/UnsafeExpr.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ object UnsafeExpr {
1919
* Warning: Using the undelying argument directly in the expansion of a macro may
2020
* change the parameter semantics as by-value parameter could be re-evaluated.
2121
*/
22-
def underlyingArgument[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
23-
import qctx.tasty._
22+
def underlyingArgument[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] =
2423
expr.unseal.underlyingArgument.seal.asInstanceOf[Expr[T]]
25-
}
2624

2725
// TODO generalize for any function arity (see Expr.betaReduce)
2826
/** Allows inspection or transformation of the body of the expression of function.
@@ -39,19 +37,16 @@ object UnsafeExpr {
3937
* ```
4038
*/
4139
def open[T1, R, X](f: Expr[T1 => R])(content: (Expr[R], [t] => Expr[t] => Expr[T1] => Expr[t]) => X)(using qctx: QuoteContext): X = {
42-
import qctx.tasty._
4340
val (params, bodyExpr) = paramsAndBody[R](f)
4441
content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]])
4542
}
4643

4744
def open[T1, T2, R, X](f: Expr[(T1, T2) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2]) => Expr[t]) => X)(using qctx: QuoteContext)(using DummyImplicit): X = {
48-
import qctx.tasty._
4945
val (params, bodyExpr) = paramsAndBody[R](f)
5046
content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal)).seal.asInstanceOf[Expr[t]])
5147
}
5248

5349
def open[T1, T2, T3, R, X](f: Expr[(T1, T2, T3) => R])(content: (Expr[R], [t] => Expr[t] => (Expr[T1], Expr[T2], Expr[T3]) => Expr[t]) => X)(using qctx: QuoteContext)(using DummyImplicit, DummyImplicit): X = {
54-
import qctx.tasty._
5550
val (params, bodyExpr) = paramsAndBody[R](f)
5651
content(bodyExpr, [t] => (e: Expr[t]) => (v1: Expr[T1], v2: Expr[T2], v3: Expr[T3]) => bodyFn[t](e.unseal, params, List(v1.unseal, v2.unseal, v3.unseal)).seal.asInstanceOf[Expr[t]])
5752
}

0 commit comments

Comments
 (0)