Skip to content

Commit 06eb420

Browse files
authored
Merge pull request #8502 from dotty-staging/remove-unnecessary-given-imports
Remove unnecessary given imports
2 parents ff476f7 + fa662ec commit 06eb420

File tree

15 files changed

+37
-37
lines changed

15 files changed

+37
-37
lines changed

library/src-bootstrapped/dotty/internal/StringContextMacro.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ object StringContextMacro {
5858
* @return the Expr containing the formatted and interpolated String or an error/warning if the parameters are not correct
5959
*/
6060
private def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using qctx: QuoteContext): Expr[String] = {
61-
import qctx.tasty.{_, given _}
61+
import qctx.tasty._
6262
val sourceFile = strCtxExpr.unseal.pos.sourceFile
6363

6464
def notStatic =
@@ -135,7 +135,7 @@ object StringContextMacro {
135135
* @return the Expr containing the formatted and interpolated String or an error/warning report if the parameters are not correct
136136
*/
137137
def interpolate(parts0 : List[String], args : Seq[Expr[Any]], argsExpr: Expr[Seq[Any]], reporter : Reporter)(using qctx: QuoteContext) : Expr[String] = {
138-
import qctx.tasty.{_, given _}
138+
import qctx.tasty._
139139

140140
/** Checks if the number of arguments are the same as the number of formatting strings
141141
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ 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.{_, given _}
37+
import qctx.tasty._
3838
new Matcher.QuoteMatcher[qctx.type].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
3939
}
4040

library/src/scala/internal/quoted/Matcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private[quoted] object Matcher {
1313
// TODO use flag from qctx.tasty.rootContext. Maybe -debug or add -debug-macros
1414
private final val debug = false
1515

16-
import qctx.tasty.{_, given _}
16+
import qctx.tasty._
1717
import Matching._
1818

1919
/** A map relating equivalent symbols from the scrutinee and the pattern

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ 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.{_, given _}
29+
import qctx.tasty._
3030
new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]]
3131
}
3232

library/src/scala/quoted/Const.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Const {
1515
* ```
1616
*/
1717
def unapply[T](expr: Expr[T])(using qctx: QuoteContext): Option[T] = {
18-
import qctx.tasty.{_, given _}
18+
import qctx.tasty._
1919
def rec(tree: Term): Option[T] = tree match {
2020
case Literal(c) => Some(c.value.asInstanceOf[T])
2121
case Block(Nil, e) => rec(e)

library/src/scala/quoted/Expr.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object Expr {
6161
* ```
6262
*/
6363
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.{_, given _}
64+
import qctx.tasty._
6565
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
6666
}
6767

@@ -74,19 +74,19 @@ object Expr {
7474
* ```
7575
*/
7676
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.{_, given _}
77+
import qctx.tasty._
7878
tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]])
7979
}
8080

8181
/** Returns a null expresssion equivalent to `'{null}` */
8282
def nullExpr: QuoteContext ?=> Expr[Null] = qctx ?=> {
83-
import qctx.tasty.{_, given _}
83+
import qctx.tasty._
8484
Literal(Constant(null)).seal.asInstanceOf[Expr[Null]]
8585
}
8686

8787
/** Returns a unit expresssion equivalent to `'{}` or `'{()}` */
8888
def unitExpr: QuoteContext ?=> Expr[Unit] = qctx ?=> {
89-
import qctx.tasty.{_, given _}
89+
import qctx.tasty._
9090
Literal(Constant(())).seal.asInstanceOf[Expr[Unit]]
9191
}
9292

@@ -95,7 +95,7 @@ object Expr {
9595
* will be equivalent to `'{ $s1; $s2; ...; $e }`.
9696
*/
9797
def block[T](statements: List[Expr[_]], expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
98-
import qctx.tasty.{_, given _}
98+
import qctx.tasty._
9999
Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]]
100100
}
101101

@@ -184,7 +184,7 @@ object Expr {
184184

185185
/** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */
186186
def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T)(using qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = {
187-
import qctx.tasty.{_, given _}
187+
import qctx.tasty._
188188
val elems: Seq[Expr[_]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[_]]]
189189
ofTuple(elems).cast[Tuple.InverseMap[T, Expr]]
190190
}
@@ -198,7 +198,7 @@ object Expr {
198198
* @param qctx current context
199199
*/
200200
def summon[T](using tpe: Type[T])(using qctx: QuoteContext): Option[Expr[T]] = {
201-
import qctx.tasty.{_, given _}
201+
import qctx.tasty._
202202
searchImplicit(tpe.unseal.tpe) match {
203203
case iss: ImplicitSearchSuccess => Some(iss.tree.seal.asInstanceOf[Expr[T]])
204204
case isf: ImplicitSearchFailure => None

library/src/scala/quoted/Lambda.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Lambda {
1616
* ```
1717
*/
1818
def unapply[F, Args <: Tuple, Res, G](expr: Expr[F])(using qctx: QuoteContext, tf: TupledFunction[F, Args => Res], tg: TupledFunction[G, Tuple.Map[Args, Expr] => Expr[Res]], functionType: Type[F]): Option[/*QuoteContext ?=>*/ G] = {
19-
import qctx.tasty.{_, given _ }
19+
import qctx.tasty._
2020
val argTypes = functionType.unseal.tpe match
2121
case AppliedType(_, functionArguments) => functionArguments.init.asInstanceOf[List[Type]]
2222
qctx.tasty.internal.lambdaExtractor(expr.unseal, argTypes).map { fn =>

library/src/scala/quoted/Liftable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ object Liftable {
3232
private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] {
3333
/** Lift a primitive value `n` into `'{ n }` */
3434
def toExpr(x: T) = qctx ?=> {
35-
import qctx.tasty.{_, given _}
35+
import qctx.tasty._
3636
Literal(Constant(x)).seal.asInstanceOf[Expr[T]]
3737
}
3838
}
3939

4040
given ClassIsLiftable[T] as Liftable[Class[T]] = new Liftable[Class[T]] {
4141
/** Lift a `Class[T]` into `'{ classOf[T] }` */
4242
def toExpr(x: Class[T]) = qctx ?=> {
43-
import qctx.tasty.{_, given _}
43+
import qctx.tasty._
4444
Ref(defn.Predef_classOf).appliedToType(Type(x)).seal.asInstanceOf[Expr[Class[T]]]
4545
}
4646
}

library/src/scala/quoted/QuoteContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.quoted.show.SyntaxHighlight
88
* It contains the low-level Typed AST API `tasty` meta-programming API.
99
* This API does not have the static type guarantiees that `Expr` and `Type` provide.
1010
*
11-
* @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty.{_, given _}; ... }`.
11+
* @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty._; ... }`.
1212
*/
1313
class QuoteContext(val tasty: scala.tasty.Reflection) { self =>
1414

library/src/scala/quoted/Type.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,47 @@ class Type[T <: AnyKind] private[scala] {
2222
object Type {
2323

2424
given UnitTag(using qctx: QuoteContext) as Type[Unit] = {
25-
import qctx.tasty.{_, given _}
25+
import qctx.tasty._
2626
defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]]
2727
}
2828

2929
given BooleanTag(using qctx: QuoteContext) as Type[Boolean] = {
30-
import qctx.tasty.{_, given _}
30+
import qctx.tasty._
3131
defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]]
3232
}
3333

3434
given ByteTag(using qctx: QuoteContext) as Type[Byte] = {
35-
import qctx.tasty.{_, given _}
35+
import qctx.tasty._
3636
defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]]
3737
}
3838

3939
given CharTag(using qctx: QuoteContext) as Type[Char] = {
40-
import qctx.tasty.{_, given _}
40+
import qctx.tasty._
4141
defn.CharType.seal.asInstanceOf[quoted.Type[Char]]
4242
}
4343

4444
given ShortTag(using qctx: QuoteContext) as Type[Short] = {
45-
import qctx.tasty.{_, given _}
45+
import qctx.tasty._
4646
defn.ShortType.seal.asInstanceOf[quoted.Type[Short]]
4747
}
4848

4949
given IntTag(using qctx: QuoteContext) as Type[Int] = {
50-
import qctx.tasty.{_, given _}
50+
import qctx.tasty._
5151
defn.IntType.seal.asInstanceOf[quoted.Type[Int]]
5252
}
5353

5454
given LongTag(using qctx: QuoteContext) as Type[Long] = {
55-
import qctx.tasty.{_, given _}
55+
import qctx.tasty._
5656
defn.LongType.seal.asInstanceOf[quoted.Type[Long]]
5757
}
5858

5959
given FloatTag(using qctx: QuoteContext) as Type[Float] = {
60-
import qctx.tasty.{_, given _}
60+
import qctx.tasty._
6161
defn.FloatType.seal.asInstanceOf[quoted.Type[Float]]
6262
}
6363

6464
given DoubleTag(using qctx: QuoteContext) as Type[Double] = {
65-
import qctx.tasty.{_, given _}
65+
import qctx.tasty._
6666
defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]]
6767
}
6868

library/src/scala/quoted/Varargs.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Varargs {
1616
* ```
1717
*/
1818
def apply[T](xs: Seq[Expr[T]])(using tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = {
19-
import qctx.tasty.{_, given _}
19+
import qctx.tasty._
2020
Repeated(xs.map[Term](_.unseal).toList, tp.unseal).seal.asInstanceOf[Expr[Seq[T]]]
2121
}
2222

@@ -33,7 +33,7 @@ object Varargs {
3333
* ```
3434
*/
3535
def unapply[T](expr: Expr[Seq[T]])(using qctx: QuoteContext): Option[Seq[Expr[T]]] = {
36-
import qctx.tasty.{_, given _}
36+
import qctx.tasty._
3737
def rec(tree: Term): Option[Seq[Expr[T]]] = tree match {
3838
case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.seal.asInstanceOf[Expr[T]]))
3939
case Block(Nil, e) => rec(e)

library/src/scala/quoted/matching/Sym.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Sym[T <: AnyKind] private[scala](val name: String, private[Sym] val id: Ob
2222
object Sym {
2323

2424
def unapply[T](expr: Expr[T])(using qctx: QuoteContext): Option[Sym[T]] = {
25-
import qctx.tasty.{_, given _}
25+
import qctx.tasty._
2626
expr.unseal match {
2727
case ref: Ident =>
2828
val sym = ref.symbol

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object UnsafeExpr {
2020
* change the parameter semantics as by-value parameter could be re-evaluated.
2121
*/
2222
def underlyingArgument[T](expr: Expr[T])(using qctx: QuoteContext): Expr[T] = {
23-
import qctx.tasty.{given _, _}
23+
import qctx.tasty._
2424
expr.unseal.underlyingArgument.seal.asInstanceOf[Expr[T]]
2525
}
2626

@@ -39,31 +39,31 @@ object UnsafeExpr {
3939
* ```
4040
*/
4141
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.{given _, _}
42+
import qctx.tasty._
4343
val (params, bodyExpr) = paramsAndBody[R](f)
4444
content(bodyExpr, [t] => (e: Expr[t]) => (v: Expr[T1]) => bodyFn[t](e.unseal, params, List(v.unseal)).seal.asInstanceOf[Expr[t]])
4545
}
4646

4747
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.{given _, _}
48+
import qctx.tasty._
4949
val (params, bodyExpr) = paramsAndBody[R](f)
5050
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]])
5151
}
5252

5353
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.{given _, _}
54+
import qctx.tasty._
5555
val (params, bodyExpr) = paramsAndBody[R](f)
5656
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]])
5757
}
5858

5959
private def paramsAndBody[R](using qctx: QuoteContext)(f: Expr[Any]): (List[qctx.tasty.ValDef], Expr[R]) = {
60-
import qctx.tasty.{given _, _}
60+
import qctx.tasty._
6161
val Block(List(DefDef("$anonfun", Nil, List(params), _, Some(body))), Closure(Ident("$anonfun"), None)) = f.unseal.etaExpand
6262
(params, body.seal.asInstanceOf[Expr[R]])
6363
}
6464

6565
private def bodyFn[t](using qctx: QuoteContext)(e: qctx.tasty.Term, params: List[qctx.tasty.ValDef], args: List[qctx.tasty.Term]): qctx.tasty.Term = {
66-
import qctx.tasty.{given _, _}
66+
import qctx.tasty._
6767
val map = params.map(_.symbol).zip(args).toMap
6868
new TreeMap {
6969
override def transformTerm(tree: Term)(using ctx: Context): Term =

library/src/scala/quoted/util/ExprMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait ExprMap {
99

1010
/** Map subexpressions an expression `e` with a type `tpe` */
1111
def transformChildren[T](e: Expr[T])(using qctx: QuoteContext, tpe: Type[T]): Expr[T] = {
12-
import qctx.tasty.{_, given _}
12+
import qctx.tasty._
1313
final class MapChildren() {
1414

1515
def transformStatement(tree: Statement)(using ctx: Context): Statement = {

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object MyScalaJSPlugin extends AutoPlugin {
6262
}
6363

6464
object Build {
65-
val referenceVersion = "0.23.0-bin-20200222-811dc19-NIGHTLY"
65+
val referenceVersion = "0.23.0-bin-20200305-84f2e41-NIGHTLY"
6666

6767
val baseVersion = "0.23.0"
6868
val baseSbtDottyVersion = "0.4.0"

0 commit comments

Comments
 (0)