Skip to content

Commit 31040cb

Browse files
Merge pull request #8510 from dotty-staging/remove-unnecessary-imports
Remove unnecessary imports
2 parents df17245 + 3854228 commit 31040cb

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
@@ -62,10 +62,8 @@ object Expr {
6262
* Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R])
6363
* ```
6464
*/
65-
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 = {
66-
import qctx.tasty._
65+
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 =
6766
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
68-
}
6967

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

8379
/** Returns a null expresssion equivalent to `'{null}` */
8480
def nullExpr: QuoteContext ?=> Expr[Null] = qctx ?=> {
@@ -186,7 +182,6 @@ object Expr {
186182

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

library/src/scala/quoted/Type.scala

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

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

7153
}

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)