diff --git a/community-build/community-projects/minitest b/community-build/community-projects/minitest index e3a3d85b9079..bda6c70aaeff 160000 --- a/community-build/community-projects/minitest +++ b/community-build/community-projects/minitest @@ -1 +1 @@ -Subproject commit e3a3d85b9079cb1085a059ad75a449a54aeaa963 +Subproject commit bda6c70aaeff686769dc4ac38ce31573bec93a08 diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 6a53948f8ad7..08f8a5c0f8f3 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 6a53948f8ad733896387fceec860cc6a04e068d8 +Subproject commit 08f8a5c0f8f3a3e8d25e0320e171b386e0c44bb1 diff --git a/community-build/community-projects/semanticdb b/community-build/community-projects/semanticdb index d0f81b86e82e..6584d3ea97a8 160000 --- a/community-build/community-projects/semanticdb +++ b/community-build/community-projects/semanticdb @@ -1 +1 @@ -Subproject commit d0f81b86e82ea029cfcd1dfbb98d0d66ba3e2542 +Subproject commit 6584d3ea97a83ae98cacb448ad0e0e15d5c01bc9 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index 330ec05edcdd..b2bfc9e3c107 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit 330ec05edcdd16b377df24311c4c4cd5b959bd73 +Subproject commit b2bfc9e3c1078590e130bcfcd09f4ac2d49452e3 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 3682622fce95..278c8096070b 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 3682622fce955fb09c76597be8f24872ab10a87d +Subproject commit 278c8096070b2a10ddd85c4750c737e8babc71ea diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 7b2f2192e5e5..435d9e076531 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 7b2f2192e5e520c0e5ce6396434bb3cd7e971d20 +Subproject commit 435d9e076531555ebc5bac8f196645a157bc6c11 diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index 49de5fb09d43..3c3d410b50d0 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -157,8 +157,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend if (self.symbol.is(core.Flags.JavaDefined)) Nil // FIXME should also support java packages else self.symbol.info.decls.iterator.map(definitionFromSym).toList - def PackageDef_symbol(self: PackageDef)(given Context): Symbol = self.symbol - type ClassDef = tpd.TypeDef def matchClassDef(tree: Tree)(given Context): Option[ClassDef] = tree match { @@ -171,7 +169,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def ClassDef_derived(self: ClassDef)(given Context): List[TypeTree] = ClassDef_rhs(self).derived.asInstanceOf[List[TypeTree]] def ClassDef_self(self: ClassDef)(given Context): Option[ValDef] = optional(ClassDef_rhs(self).self) def ClassDef_body(self: ClassDef)(given Context): List[Statement] = ClassDef_rhs(self).body - def ClassDef_symbol(self: ClassDef)(given Context): Symbol = self.symbol.asClass private def ClassDef_rhs(self: ClassDef) = self.rhs.asInstanceOf[tpd.Template] def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Term | TypeTree], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(given Context): ClassDef = { @@ -187,7 +184,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend } def TypeDef_rhs(self: TypeDef)(given Context): TypeTree | TypeBoundsTree = self.rhs - def TypeDef_symbol(self: TypeDef)(given Context): Symbol = self.symbol.asType def TypeDef_apply(symbol: Symbol)(given Context): TypeDef = withDefaultPos(tpd.TypeDef(symbol.asType)) def TypeDef_copy(original: TypeDef)(name: String, rhs: TypeTree | TypeBoundsTree)(given Context): TypeDef = @@ -204,7 +200,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def DefDef_paramss(self: DefDef)(given Context): List[List[ValDef]] = self.vparamss def DefDef_returnTpt(self: DefDef)(given Context): TypeTree = self.tpt def DefDef_rhs(self: DefDef)(given Context): Option[Tree] = optional(self.rhs) - def DefDef_symbol(self: DefDef)(given Context): Symbol = self.symbol.asTerm def DefDef_apply(symbol: Symbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(given Context): DefDef = withDefaultPos(tpd.polyDefDef(symbol.asTerm, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree))) @@ -221,7 +216,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend def ValDef_tpt(self: ValDef)(given Context): TypeTree = self.tpt def ValDef_rhs(self: ValDef)(given Context): Option[Tree] = optional(self.rhs) - def ValDef_symbol(self: ValDef)(given Context): Symbol = self.symbol.asTerm def ValDef_apply(symbol: Symbol, rhs: Option[Term])(given Context): ValDef = tpd.ValDef(symbol.asTerm, rhs.getOrElse(tpd.EmptyTree)) @@ -238,7 +232,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => None } - def Term_pos(self: Term)(given Context): Position = self.sourcePos def Term_tpe(self: Term)(given Context): Type = self.tpe def Term_underlyingArgument(self: Term)(given Context): Term = self.underlyingArgument def Term_underlying(self: Term)(given Context): Term = self.underlying @@ -629,7 +622,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend val NameKinds.OuterSelectName(_, levels) = self.name levels } - def SelectOuter_tpe(self: SelectOuter)(given Context): Type = self.tpe.stripTypeVar def SelectOuter_apply(qualifier: Term, name: String, levels: Int)(given Context): SelectOuter = withDefaultPos(tpd.Select(qualifier, NameKinds.OuterSelectName(name.toTermName, levels))) @@ -660,8 +652,6 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend case _ => if (x.isType) Some(x) else None } - def TypeTree_pos(self: TypeTree)(given Context): Position = self.sourcePos - def TypeTree_symbol(self: TypeTree)(given Context): Symbol = self.symbol def TypeTree_tpe(self: TypeTree)(given Context): Type = self.tpe.stripTypeVar type Inferred = tpd.TypeTree diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala index 4c468a26e5cf..a01ccb673961 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala @@ -18,7 +18,8 @@ object ReflectionImpl { val syntaxHighlight = if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI else SyntaxHighlight.plain - new refl.SourceCodePrinter(syntaxHighlight).showTree(reflTree)(given reflCtx) + val printers = new scala.tasty.reflect.Printers(refl) + new printers.SourceCodePrinter(syntaxHighlight).showTree(reflTree)(given reflCtx) } } diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index c33bc14953fb..5ab40ba057d9 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -29,14 +29,14 @@ import scala.quoted._ inline def natConst(x: => Int): Int = ${natConstImpl('{x})} def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} ... } ``` ### Sealing and Unsealing -`import qctx.tasty._` will provide an `unseal` extension method on `quoted.Expr` +`import qctx.tasty.{_, given}` will provide an `unseal` extension method on `quoted.Expr` and `quoted.Type` which returns a `qctx.tasty.Term` that represents the tree of the expression and `qctx.tasty.TypeTree` that represents the tree of the type respectively. It will also import all extractors and methods on TASTy Reflect @@ -44,7 +44,7 @@ trees. For example the `Literal(_)` extractor used below. ```scala def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val xTree: Term = x.unseal xTree match { case Inlined(_, _, Literal(Constant(n: Int))) => @@ -81,7 +81,7 @@ operation expression passed while calling the `macro` below. inline def macro(param: => Boolean): Unit = ${ macroImpl('param) } def macroImpl(param: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ param.unseal.underlyingArgument match { @@ -103,7 +103,7 @@ point. ```scala def macroImpl()(qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val pos = rootPosition val path = pos.sourceFile.jpath.toString diff --git a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala index bddd67e3176f..3ed195bdedfb 100644 --- a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala +++ b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala @@ -82,7 +82,7 @@ object StringContextMacro { * quotes an error if the given Expr does not contain a list of arguments */ def getArgsExprs(argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Option[List[Expr[Any]]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} argsExpr.unseal.underlyingArgument match { case Typed(Repeated(args, _), _) => Some(args.map(_.seal)) @@ -99,7 +99,7 @@ object StringContextMacro { * @return the Expr containing the formatted and interpolated String or an error/warning if the parameters are not correct */ private def interpolate(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val sourceFile = strCtxExpr.unseal.pos.sourceFile val (partsExpr, parts) = getPartsExprs(strCtxExpr) match { @@ -165,7 +165,7 @@ object StringContextMacro { * @return the Expr containing the formatted and interpolated String or an error/warning report if the parameters are not correct */ def interpolate(parts0 : List[String], args : List[Expr[Any]], argsExpr: Expr[Seq[Any]], reporter : Reporter)(given qctx: QuoteContext) : Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} /** Checks if the number of arguments are the same as the number of formatting strings * diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 7d9efd98b0f9..0cb32a593c0b 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -32,7 +32,7 @@ object Liftable { private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] { /** Lift a primitive value `n` into `'{ n }` */ def toExpr(x: T) = (given qctx) => { - import qctx.tasty._ + import qctx.tasty.{_, given} Literal(Constant(x)).seal.asInstanceOf[Expr[T]] } } @@ -40,7 +40,7 @@ object Liftable { given ClassIsLiftable[T] : Liftable[Class[T]] = new Liftable[Class[T]] { /** Lift a `Class[T]` into `'{ classOf[T] }` */ def toExpr(x: Class[T]) = (given qctx) => { - import qctx.tasty._ + import qctx.tasty.{_, given} Ref(defn.Predef_classOf).appliedToType(Type(x)).seal.asInstanceOf[Expr[Class[T]]] } } diff --git a/library/src/scala/internal/quoted/Expr.scala b/library/src/scala/internal/quoted/Expr.scala index dd28d1c2dc99..227f30faec89 100644 --- a/library/src/scala/internal/quoted/Expr.scala +++ b/library/src/scala/internal/quoted/Expr.scala @@ -27,7 +27,7 @@ object Expr { */ def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: Expr[_])(implicit patternExpr: Expr[_], hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = { - import qctx.tasty._ + import qctx.tasty.{_, given} new Matcher.QuoteMatcher[qctx.type].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf[Option[Tup]] } diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index d3c8ce7c2c14..af99fbdc027f 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -12,7 +12,7 @@ private[quoted] object Matcher { private final val debug = false - import qctx.tasty._ + import qctx.tasty.{_, given} import Matching._ private type Env = Set[(Symbol, Symbol)] diff --git a/library/src/scala/internal/quoted/Type.scala b/library/src/scala/internal/quoted/Type.scala index c754aa79441e..ca7b2368367c 100644 --- a/library/src/scala/internal/quoted/Type.scala +++ b/library/src/scala/internal/quoted/Type.scala @@ -19,7 +19,7 @@ object Type { */ def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: Type[_])(implicit patternType: Type[_], hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = { - import qctx.tasty._ + import qctx.tasty.{_, given} new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]] } diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index 086f39cd0ae0..d533ac680f0f 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -37,7 +37,7 @@ package quoted { * ``` */ def betaReduce[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, Args => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { - import qctx.tasty._ + import qctx.tasty.{_, given} tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } @@ -51,19 +51,19 @@ package quoted { * Note: The */ def betaReduceGiven[F, Args <: Tuple, R, G](f: Expr[F])(given tf: TupledFunction[F, (given Args) => R], tg: TupledFunction[G, TupleOfExpr[Args] => Expr[R]], qctx: QuoteContext): G = { - import qctx.tasty._ + import qctx.tasty.{_, given} tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) } /** Returns a null expresssion equivalent to `'{null}` */ def nullExpr: (given QuoteContext) => Expr[Null] = (given qctx) => { - import qctx.tasty._ + import qctx.tasty.{_, given} Literal(Constant(null)).seal.asInstanceOf[Expr[Null]] } /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */ def unitExpr: (given QuoteContext) => Expr[Unit] = (given qctx) => { - import qctx.tasty._ + import qctx.tasty.{_, given} Literal(Constant(())).seal.asInstanceOf[Expr[Unit]] } @@ -72,7 +72,7 @@ package quoted { * will be equivalent to `'{ $s1; $s2; ...; $e }`. */ def block[T](statements: List[Expr[_]], expr: Expr[T])(given qctx: QuoteContext): Expr[T] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]] } @@ -92,7 +92,7 @@ package quoted { * ``` */ def ofSeq[T](xs: Seq[Expr[T]])(given tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Repeated(xs.map(_.unseal).toList, tp.unseal).seal.asInstanceOf[Expr[Seq[T]]] } @@ -168,8 +168,8 @@ package quoted { } /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */ - def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T) (given ctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = { - import ctx.tasty._ + def ofTuple[T <: Tuple: Tuple.IsMappedBy[Expr]: Type](tup: T) (given qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = { + import qctx.tasty.{_, given} val elems: Seq[Expr[_]] = tup.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Expr[_]]] ofTuple(elems).cast[Tuple.InverseMap[T, Expr]] } diff --git a/library/src/scala/quoted/QuoteContext.scala b/library/src/scala/quoted/QuoteContext.scala index 3f81928678d6..6831663e4a0f 100644 --- a/library/src/scala/quoted/QuoteContext.scala +++ b/library/src/scala/quoted/QuoteContext.scala @@ -8,41 +8,41 @@ import scala.quoted.show.SyntaxHighlight * It contains the low-level Typed AST API `tasty` meta-programming API. * This API does not have the static type guarantiees that `Expr` and `Type` provide. * - * @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty._; ... }`. + * @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty.{_, given}; ... }`. */ class QuoteContext(val tasty: scala.tasty.Reflection) { def show(expr: Expr[_], syntaxHighlight: SyntaxHighlight): String = { - import tasty._ + import tasty.{_, given} expr.unseal.show(syntaxHighlight) } def show(tpe: Type[_], syntaxHighlight: SyntaxHighlight): String = { - import tasty._ + import tasty.{_, given} tpe.unseal.show(syntaxHighlight) } /** Report an error */ def error(msg: => String): Unit = { - import tasty._ + import tasty.{_, given} tasty.error(msg, rootPosition)(given rootContext) } /** Report an error at the on the position of `expr` */ def error(msg: => String, expr: Expr[_]): Unit = { - import tasty._ + import tasty.{_, given} tasty.error(msg, expr.unseal.pos)(given rootContext) } /** Report a warning */ def warning(msg: => String): Unit = { - import tasty._ + import tasty.{_, given} tasty.warning(msg, rootPosition)(given rootContext) } /** Report a warning at the on the position of `expr` */ def warning(msg: => String, expr: Expr[_]): Unit = { - import tasty._ + import tasty.{_, given} tasty.warning(msg, expr.unseal.pos)(given rootContext) } diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index 7744cc842c2d..73ae4144e0ab 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -18,47 +18,47 @@ package quoted { object Type { given UnitTag(given qctx: QuoteContext): Type[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]] } given BooleanTag(given qctx: QuoteContext): Type[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]] } given ByteTag(given qctx: QuoteContext): Type[Byte] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]] } given CharTag(given qctx: QuoteContext): Type[Char] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.CharType.seal.asInstanceOf[quoted.Type[Char]] } given ShortTag(given qctx: QuoteContext): Type[Short] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.ShortType.seal.asInstanceOf[quoted.Type[Short]] } given IntTag(given qctx: QuoteContext): Type[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.IntType.seal.asInstanceOf[quoted.Type[Int]] } given LongTag(given qctx: QuoteContext): Type[Long] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.LongType.seal.asInstanceOf[quoted.Type[Long]] } given FloatTag(given qctx: QuoteContext): Type[Float] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.FloatType.seal.asInstanceOf[quoted.Type[Float]] } given DoubleTag(given qctx: QuoteContext): Type[Double] = { - import qctx.tasty._ + import qctx.tasty.{_, given} defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]] } diff --git a/library/src/scala/quoted/matching/Const.scala b/library/src/scala/quoted/matching/Const.scala index e7b790a08041..3d3e61bf5ef7 100644 --- a/library/src/scala/quoted/matching/Const.scala +++ b/library/src/scala/quoted/matching/Const.scala @@ -15,7 +15,7 @@ package matching object Const { def unapply[T](expr: Expr[T])(given qctx: QuoteContext): Option[T] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def rec(tree: Term): Option[T] = tree match { case Literal(c) => Some(c.value.asInstanceOf[T]) case Block(Nil, e) => rec(e) diff --git a/library/src/scala/quoted/matching/ExprSeq.scala b/library/src/scala/quoted/matching/ExprSeq.scala index d80e8146dcd4..fc29a771a1a5 100644 --- a/library/src/scala/quoted/matching/ExprSeq.scala +++ b/library/src/scala/quoted/matching/ExprSeq.scala @@ -6,7 +6,7 @@ object ExprSeq { /** Matches a literal sequence of expressions */ def unapply[T](expr: Expr[Seq[T]])(given qctx: QuoteContext): Option[Seq[Expr[T]]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def rec(tree: Term): Option[Seq[Expr[T]]] = tree match { case Typed(Repeated(elems, _), _) => Some(elems.map(x => x.seal.asInstanceOf[Expr[T]])) case Block(Nil, e) => rec(e) diff --git a/library/src/scala/quoted/matching/Sym.scala b/library/src/scala/quoted/matching/Sym.scala index 17f44d44923a..afcae7718296 100644 --- a/library/src/scala/quoted/matching/Sym.scala +++ b/library/src/scala/quoted/matching/Sym.scala @@ -20,7 +20,7 @@ class Sym[T <: AnyKind] private[scala](val name: String, private[Sym] val id: Ob object Sym { def unapply[T](expr: Expr[T])(given qctx: QuoteContext): Option[Sym[T]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} expr.unseal match { case IsIdent(ref) => val sym = ref.symbol diff --git a/library/src/scala/quoted/matching/package.scala b/library/src/scala/quoted/matching/package.scala index eee039991097..fad5fa0ed2d1 100644 --- a/library/src/scala/quoted/matching/package.scala +++ b/library/src/scala/quoted/matching/package.scala @@ -11,7 +11,7 @@ package object matching { * @param qctx current context */ def searchImplicitExpr[T](given tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} searchImplicit(tpe.unseal.tpe) match { case IsImplicitSearchSuccess(iss) => Some(iss.tree.seal.asInstanceOf[Expr[T]]) case IsImplicitSearchFailure(isf) => None diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 90b4d2052cac..aa11d80feb31 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -14,7 +14,7 @@ class Reflection(private[scala] val internal: CompilerInterface) with ImportSelectorOps with QuotedOps with PositionOps - with Printers + with PrinterOps with ReportingOps with RootPosition with SignatureOps diff --git a/library/src/scala/tasty/reflect/CommentOps.scala b/library/src/scala/tasty/reflect/CommentOps.scala index 3205a3f8a523..0995f010a184 100644 --- a/library/src/scala/tasty/reflect/CommentOps.scala +++ b/library/src/scala/tasty/reflect/CommentOps.scala @@ -2,7 +2,7 @@ package scala.tasty.reflect trait CommentOps extends Core { - implicit class CommentAPI(self: Comment) { + given (self: Comment) { /** Raw comment string */ def raw: String = internal.Comment_raw(self) diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index c91fdcc3e20a..1fa05958fbbb 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -227,7 +227,6 @@ trait CompilerInterface { def PackageDef_owner(self: PackageDef)(given ctx: Context): PackageDef def PackageDef_members(self: PackageDef)(given ctx: Context): List[Statement] - def PackageDef_symbol(self: PackageDef)(given ctx: Context): Symbol /** Tree representing a class definition. This includes annonymus class definitions and the class of a module object */ type ClassDef <: Definition @@ -239,7 +238,6 @@ trait CompilerInterface { def ClassDef_derived(self: ClassDef)(given ctx: Context): List[TypeTree] def ClassDef_self(self: ClassDef)(given ctx: Context): Option[ValDef] def ClassDef_body(self: ClassDef)(given ctx: Context): List[Statement] - def ClassDef_symbol(self: ClassDef)(given ctx: Context): Symbol def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree/* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(given ctx: Context): ClassDef @@ -249,7 +247,6 @@ trait CompilerInterface { def matchTypeDef(tree: Tree)(given ctx: Context): Option[TypeDef] def TypeDef_rhs(self: TypeDef)(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ - def TypeDef_symbol(self: TypeDef)(given ctx: Context): Symbol def TypeDef_apply(symbol: Symbol)(given ctx: Context): TypeDef def TypeDef_copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(given ctx: Context): TypeDef @@ -263,7 +260,6 @@ trait CompilerInterface { def DefDef_paramss(self: DefDef)(given ctx: Context): List[List[ValDef]] def DefDef_returnTpt(self: DefDef)(given ctx: Context): TypeTree def DefDef_rhs(self: DefDef)(given ctx: Context): Option[Term] - def DefDef_symbol(self: DefDef)(given ctx: Context): Symbol def DefDef_apply(symbol: Symbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(given ctx: Context): DefDef def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(given ctx: Context): DefDef @@ -275,7 +271,6 @@ trait CompilerInterface { def ValDef_tpt(self: ValDef)(given ctx: Context): TypeTree def ValDef_rhs(self: ValDef)(given ctx: Context): Option[Term] - def ValDef_symbol(self: ValDef)(given ctx: Context): Symbol def ValDef_apply(symbol: Symbol, rhs: Option[Term])(given ctx: Context): ValDef def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(given ctx: Context): ValDef @@ -285,7 +280,6 @@ trait CompilerInterface { def matchTerm(tree: Tree)(given ctx: Context): Option[Term] - def Term_pos(self: Term)(given ctx: Context): Position def Term_tpe(self: Term)(given ctx: Context): Type def Term_underlyingArgument(self: Term)(given ctx: Context): Term def Term_underlying(self: Term)(given ctx: Context): Term @@ -533,7 +527,6 @@ trait CompilerInterface { def SelectOuter_qualifier(self: SelectOuter)(given ctx: Context): Term def SelectOuter_level(self: SelectOuter)(given ctx: Context): Int - def SelectOuter_tpe(self: SelectOuter)(given ctx: Context): Type def SelectOuter_apply(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter def SelectOuter_copy(original: Tree)(qualifier: Term, name: String, levels: Int)(given ctx: Context): SelectOuter @@ -554,8 +547,6 @@ trait CompilerInterface { def matchTypeTree(tree: Tree)(given ctx: Context): Option[TypeTree] - def TypeTree_pos(self: TypeTree)(given ctx: Context): Position - def TypeTree_symbol(self: TypeTree)(given ctx: Context): Symbol def TypeTree_tpe(self: TypeTree)(given ctx: Context): Type /** Type tree representing an inferred type */ diff --git a/library/src/scala/tasty/reflect/ConstantOps.scala b/library/src/scala/tasty/reflect/ConstantOps.scala index 07ca627a0ea3..22d2bace2cd3 100644 --- a/library/src/scala/tasty/reflect/ConstantOps.scala +++ b/library/src/scala/tasty/reflect/ConstantOps.scala @@ -3,7 +3,7 @@ package reflect trait ConstantOps extends Core { - implicit class ConstantAPI(const: Constant) { + given (const: Constant) { def value: Any = internal.Constant_value(const) } diff --git a/library/src/scala/tasty/reflect/ContextOps.scala b/library/src/scala/tasty/reflect/ContextOps.scala index ccfb45e95fdb..15597c9eb60f 100644 --- a/library/src/scala/tasty/reflect/ContextOps.scala +++ b/library/src/scala/tasty/reflect/ContextOps.scala @@ -3,7 +3,7 @@ package reflect trait ContextOps extends Core { - implicit class ContextAPI(self: Context) { + given (self: Context) { /** Returns the owner of the context */ def owner: Symbol = internal.Context_owner(self) diff --git a/library/src/scala/tasty/reflect/FlagsOps.scala b/library/src/scala/tasty/reflect/FlagsOps.scala index 36432de4e241..54b4ae2271c9 100644 --- a/library/src/scala/tasty/reflect/FlagsOps.scala +++ b/library/src/scala/tasty/reflect/FlagsOps.scala @@ -2,7 +2,7 @@ package scala.tasty.reflect trait FlagsOps extends Core { - implicit class FlagsAPI(self: Flags) { + given (self: Flags) { /** Is the given flag set a subset of this flag sets */ def is(that: Flags): Boolean = internal.Flags_is(self)(that) diff --git a/library/src/scala/tasty/reflect/IdOps.scala b/library/src/scala/tasty/reflect/IdOps.scala index d1088dfafcc6..b56c38986db8 100644 --- a/library/src/scala/tasty/reflect/IdOps.scala +++ b/library/src/scala/tasty/reflect/IdOps.scala @@ -3,7 +3,7 @@ package reflect trait IdOps extends Core { - implicit class IdAPI(id: Id) { + given (id: Id) { /** Position in the source code */ def pos(given ctx: Context): Position = internal.Id_pos(id) diff --git a/library/src/scala/tasty/reflect/ImplicitsOps.scala b/library/src/scala/tasty/reflect/ImplicitsOps.scala index d8310d2ee0c9..4fb1a473e5f3 100644 --- a/library/src/scala/tasty/reflect/ImplicitsOps.scala +++ b/library/src/scala/tasty/reflect/ImplicitsOps.scala @@ -10,7 +10,7 @@ trait ImplicitsOps extends Core { internal.matchImplicitSearchSuccess(isr) } - implicit class IsImplicitSearchSuccessAPI(self: ImplicitSearchSuccess) { + given (self: ImplicitSearchSuccess) { def tree(given ctx: Context): Term = internal.ImplicitSearchSuccess_tree(self) } @@ -19,7 +19,7 @@ trait ImplicitsOps extends Core { internal.matchImplicitSearchFailure(isr) } - implicit class ImplicitSearchFailureAPI(self: ImplicitSearchFailure) { + given (self: ImplicitSearchFailure) { def explanation(given ctx: Context): String = internal.ImplicitSearchFailure_explanation(self) } diff --git a/library/src/scala/tasty/reflect/ImportSelectorOps.scala b/library/src/scala/tasty/reflect/ImportSelectorOps.scala index f9eb0646ec8a..59dbf7981aa5 100644 --- a/library/src/scala/tasty/reflect/ImportSelectorOps.scala +++ b/library/src/scala/tasty/reflect/ImportSelectorOps.scala @@ -3,7 +3,7 @@ package reflect trait ImportSelectorOps extends Core { - implicit class SimpleSelectorAPI(self: SimpleSelector) { + given (self: SimpleSelector) { def selection(given ctx: Context): Id = internal.SimpleSelector_selection(self) } @@ -13,7 +13,7 @@ trait ImportSelectorOps extends Core { internal.matchSimpleSelector(importSelector).map(_.selection) } - implicit class RenameSelectorAPI(self: RenameSelector) { + given (self: RenameSelector) { def from(given ctx: Context): Id = internal.RenameSelector_from(self) @@ -26,7 +26,7 @@ trait ImportSelectorOps extends Core { internal.matchRenameSelector(importSelector).map(x => (x.from, x.to)) } - implicit class OmitSelectorAPI(self: OmitSelector) { + given (self: OmitSelector) { def omitted(given ctx: Context): Id = internal.SimpleSelector_omitted(self) } diff --git a/library/src/scala/tasty/reflect/PositionOps.scala b/library/src/scala/tasty/reflect/PositionOps.scala index e54f5da5a4a5..43e4af171c53 100644 --- a/library/src/scala/tasty/reflect/PositionOps.scala +++ b/library/src/scala/tasty/reflect/PositionOps.scala @@ -2,7 +2,7 @@ package scala.tasty.reflect trait PositionOps extends Core { - implicit class PositionAPI(pos: Position) { + given (pos: Position) { /** The start offset in the source file */ def start: Int = internal.Position_start(pos) @@ -33,7 +33,7 @@ trait PositionOps extends Core { } - implicit class SourceFileAPI(sourceFile: SourceFile) { + given (sourceFile: SourceFile) { /** Path to this source file */ def jpath: java.nio.file.Path = internal.SourceFile_jpath(sourceFile) diff --git a/library/src/scala/tasty/reflect/PrinterOps.scala b/library/src/scala/tasty/reflect/PrinterOps.scala new file mode 100644 index 000000000000..c7693f180b66 --- /dev/null +++ b/library/src/scala/tasty/reflect/PrinterOps.scala @@ -0,0 +1,90 @@ +package scala.tasty +package reflect + +import scala.quoted.show.SyntaxHighlight + +trait PrinterOps extends Core { self: Reflection => + + /** Adds `show` as an extension method of a `Tree` */ + implicit class TreeShowDeco(tree: Tree) { + /** Shows the tree as extractors */ + def showExtractors(given ctx: Context): String = + val printers = new Printers(self) + new printers.ExtractorsPrinter().showTree(tree) + + /** Shows the tree as fully typed source code */ + def show(given ctx: Context): String = show(SyntaxHighlight.plain) + + /** Shows the tree as fully typed source code */ + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = + val printers = new Printers(self) + new printers.SourceCodePrinter(syntaxHighlight).showTree(tree) + + } + + /** Adds `show` as an extension method of a `TypeOrBounds` */ + implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) { + /** Shows the tree as extractors */ + def showExtractors(given ctx: Context): String = + val printers = new Printers(self) + new printers.ExtractorsPrinter().showTypeOrBounds(tpe) + + /** Shows the tree as fully typed source code */ + def show(given ctx: Context): String = show(SyntaxHighlight.plain) + + /** Shows the tree as fully typed source code */ + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = + val printers = new Printers(self) + new printers.SourceCodePrinter(syntaxHighlight).showTypeOrBounds(tpe) + } + + /** Adds `show` as an extension method of a `Constant` */ + implicit class ConstantShowDeco(const: Constant) { + /** Shows the tree as extractors */ + def showExtractors(given ctx: Context): String = + val printers = new Printers(self) + new printers.ExtractorsPrinter().showConstant(const) + + /** Shows the tree as fully typed source code */ + def show(given ctx: Context): String = show(SyntaxHighlight.plain) + + /** Shows the tree as fully typed source code */ + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = + val printers = new Printers(self) + new printers.SourceCodePrinter(syntaxHighlight).showConstant(const) + } + + /** Adds `show` as an extension method of a `Symbol` */ + implicit class SymbolShowDeco(symbol: Symbol) { + /** Shows the tree as extractors */ + def showExtractors(given ctx: Context): String = + val printers = new Printers(self) + new printers.ExtractorsPrinter().showSymbol(symbol) + + /** Shows the tree as fully typed source code */ + def show(given ctx: Context): String = show(SyntaxHighlight.plain) + + /** Shows the tree as fully typed source code */ + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = + val printers = new Printers(self) + new printers.SourceCodePrinter(syntaxHighlight).showSymbol(symbol) + } + + /** Adds `show` as an extension method of a `Flags` */ + implicit class FlagsShowDeco(flags: Flags) { + /** Shows the tree as extractors */ + def showExtractors(given ctx: Context): String = + val printers = new Printers(self) + new printers.ExtractorsPrinter().showFlags(flags) + + /** Shows the tree as fully typed source code */ + def show(given ctx: Context): String = show(SyntaxHighlight.plain) + + /** Shows the tree as fully typed source code */ + def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = + val printers = new Printers(self) + new printers.SourceCodePrinter(syntaxHighlight).showFlags(flags) + } + + +} diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index d38f40219633..29fa630cf874 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -4,84 +4,9 @@ package reflect import scala.annotation.switch import scala.quoted.show.SyntaxHighlight -trait Printers - extends Core - with ConstantOps - with FlagsOps - with IdOps - with ImportSelectorOps - with PositionOps - with SignatureOps - with StandardDefinitions - with SymbolOps - with TreeOps - with TypeOrBoundsOps { - - /** Adds `show` as an extension method of a `Tree` */ - implicit class TreeShowDeco(tree: Tree) { - /** Shows the tree as extractors */ - def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showTree(tree) - - /** Shows the tree as fully typed source code */ - def show(given ctx: Context): String = show(SyntaxHighlight.plain) - - /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = - new SourceCodePrinter(syntaxHighlight).showTree(tree) - } - - /** Adds `show` as an extension method of a `TypeOrBounds` */ - implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) { - /** Shows the tree as extractors */ - def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showTypeOrBounds(tpe) - - /** Shows the tree as fully typed source code */ - def show(given ctx: Context): String = show(SyntaxHighlight.plain) - - /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = - new SourceCodePrinter(syntaxHighlight).showTypeOrBounds(tpe) - } - - /** Adds `show` as an extension method of a `Constant` */ - implicit class ConstantShowDeco(const: Constant) { - /** Shows the tree as extractors */ - def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showConstant(const) - - /** Shows the tree as fully typed source code */ - def show(given ctx: Context): String = show(SyntaxHighlight.plain) - - /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = - new SourceCodePrinter(syntaxHighlight).showConstant(const) - } - - /** Adds `show` as an extension method of a `Symbol` */ - implicit class SymbolShowDeco(symbol: Symbol) { - /** Shows the tree as extractors */ - def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showSymbol(symbol) - - /** Shows the tree as fully typed source code */ - def show(given ctx: Context): String = show(SyntaxHighlight.plain) - - /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = - new SourceCodePrinter(syntaxHighlight).showSymbol(symbol) - } - - /** Adds `show` as an extension method of a `Flags` */ - implicit class FlagsShowDeco(flags: Flags) { - /** Shows the tree as extractors */ - def showExtractors(given ctx: Context): String = new ExtractorsPrinter().showFlags(flags) - - /** Shows the tree as fully typed source code */ - def show(given ctx: Context): String = show(SyntaxHighlight.plain) - - /** Shows the tree as fully typed source code */ - def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String = - new SourceCodePrinter(syntaxHighlight).showFlags(flags) - } +class Printers[R <: Reflection & Singleton](val tasty: R) { + import tasty.{_, given} abstract class Printer { diff --git a/library/src/scala/tasty/reflect/QuotedOps.scala b/library/src/scala/tasty/reflect/QuotedOps.scala index 651fa3bd2351..8b7b97f5992f 100644 --- a/library/src/scala/tasty/reflect/QuotedOps.scala +++ b/library/src/scala/tasty/reflect/QuotedOps.scala @@ -1,7 +1,7 @@ package scala.tasty.reflect /** Extension methods on scala.quoted.{Expr|Type} to convert to scala.tasty.Tasty objects */ -trait QuotedOps extends Core { self: Printers => +trait QuotedOps extends Core { implicit class QuotedExprAPI[T](expr: scala.quoted.Expr[T]) { /** View this expression `quoted.Expr[T]` as a `Term` */ diff --git a/library/src/scala/tasty/reflect/SignatureOps.scala b/library/src/scala/tasty/reflect/SignatureOps.scala index d03026a625a2..ca2a2f713df0 100644 --- a/library/src/scala/tasty/reflect/SignatureOps.scala +++ b/library/src/scala/tasty/reflect/SignatureOps.scala @@ -9,7 +9,7 @@ trait SignatureOps extends Core { Some((sig.paramSigs, sig.resultSig)) } - implicit class SignatureAPI(sig: Signature) { + given (sig: Signature) { /** The signatures of the method parameters. * diff --git a/library/src/scala/tasty/reflect/SymbolOps.scala b/library/src/scala/tasty/reflect/SymbolOps.scala index 914db2037e1d..1bdcf2229a79 100644 --- a/library/src/scala/tasty/reflect/SymbolOps.scala +++ b/library/src/scala/tasty/reflect/SymbolOps.scala @@ -14,7 +14,7 @@ trait SymbolOps extends Core { selfSymbolOps: FlagsOps => internal.Symbol_noSymbol } - implicit class SymbolAPI(self: Symbol) { + given (self: Symbol) { /** Owner of this symbol. The owner is the symbol in which this symbol is defined */ def owner(given ctx: Context): Symbol = internal.Symbol_owner(self) diff --git a/library/src/scala/tasty/reflect/TreeOps.scala b/library/src/scala/tasty/reflect/TreeOps.scala index 52ea20496372..4b2068eeb159 100644 --- a/library/src/scala/tasty/reflect/TreeOps.scala +++ b/library/src/scala/tasty/reflect/TreeOps.scala @@ -5,7 +5,7 @@ trait TreeOps extends Core { // ----- Tree ----------------------------------------------------- - implicit class TreeAPI(self: Tree) { + given (self: Tree) { /** Position in the source code */ def pos(given ctx: Context): Position = internal.Tree_pos(self) @@ -26,7 +26,7 @@ trait TreeOps extends Core { internal.matchPackageClause(tree).map(x => (x.pid, x.stats)) } - implicit class PackageClauseAPI(self: PackageClause) { + given (self: PackageClause) { def pid(given ctx: Context): Ref = internal.PackageClause_pid(self) def stats(given ctx: Context): List[Tree] = internal.PackageClause_stats(self) } @@ -45,7 +45,7 @@ trait TreeOps extends Core { internal.matchImport(tree).map(x => (x.expr, x.selectors)) } - implicit class ImportAPI(self: Import) { + given (self: Import) { def expr(given ctx: Context): Term = internal.Import_expr(self) def selectors(given ctx: Context): List[ImportSelector] = internal.Import_selectors(self) @@ -62,7 +62,7 @@ trait TreeOps extends Core { def unapply(tree: Tree)(given ctx: Context): Option[Definition] = internal.matchDefinition(tree) } - implicit class DefinitionAPI(self: Definition) { + given (self: Definition) { def name(given ctx: Context): String = internal.Definition_name(self) } @@ -80,13 +80,12 @@ trait TreeOps extends Core { internal.matchClassDef(tree).map(x => (x.name, x.constructor, x.parents, x.derived, x.self, x.body)) } - implicit class ClassDefAPI(self: ClassDef) { + given (self: ClassDef) { def constructor(given ctx: Context): DefDef = internal.ClassDef_constructor(self) def parents(given ctx: Context): List[Tree /* Term | TypeTree */] = internal.ClassDef_parents(self) def derived(given ctx: Context): List[TypeTree] = internal.ClassDef_derived(self) def self(given ctx: Context): Option[ValDef] = internal.ClassDef_self(self) def body(given ctx: Context): List[Statement] = internal.ClassDef_body(self) - def symbol(given ctx: Context): Symbol = internal.ClassDef_symbol(self) } // DefDef @@ -104,12 +103,11 @@ trait TreeOps extends Core { internal.matchDefDef(tree).map(x => (x.name, x.typeParams, x.paramss, x.returnTpt, x.rhs)) } - implicit class DefDefAPI(self: DefDef) { + given (self: DefDef) { def typeParams(given ctx: Context): List[TypeDef] = internal.DefDef_typeParams(self) def paramss(given ctx: Context): List[List[ValDef]] = internal.DefDef_paramss(self) def returnTpt(given ctx: Context): TypeTree = internal.DefDef_returnTpt(self) // TODO rename to tpt def rhs(given ctx: Context): Option[Term] = internal.DefDef_rhs(self) - def symbol(given ctx: Context): Symbol = internal.DefDef_symbol(self) } // ValDef @@ -127,10 +125,9 @@ trait TreeOps extends Core { internal.matchValDef(tree).map(x => (x.name, x.tpt, x.rhs)) } - implicit class ValDefAPI(self: ValDef) { + given (self: ValDef) { def tpt(given ctx: Context): TypeTree = internal.ValDef_tpt(self) def rhs(given ctx: Context): Option[Term] = internal.ValDef_rhs(self) - def symbol(given ctx: Context): Symbol = internal.ValDef_symbol(self) } // TypeDef @@ -148,9 +145,8 @@ trait TreeOps extends Core { internal.matchTypeDef(tree).map(x => (x.name, x.rhs)) } - implicit class TypeDefAPI(self: TypeDef) { + given (self: TypeDef) { def rhs(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeDef_rhs(self) - def symbol(given ctx: Context): Symbol = internal.TypeDef_symbol(self) } // PackageDef @@ -160,10 +156,9 @@ trait TreeOps extends Core { internal.matchPackageDef(tree) } - implicit class PackageDefAPI(self: PackageDef) { + given (self: PackageDef) { def owner(given ctx: Context): PackageDef = internal.PackageDef_owner(self) def members(given ctx: Context): List[Statement] = internal.PackageDef_members(self) - def symbol(given ctx: Context): Symbol = internal.PackageDef_symbol(self) } object PackageDef { @@ -173,19 +168,18 @@ trait TreeOps extends Core { // ----- Terms ---------------------------------------------------- - implicit class TermAPI(self: Term) { + given (self: Term) { def tpe(given ctx: Context): Type = internal.Term_tpe(self) - def pos(given ctx: Context): Position = internal.Term_pos(self) def underlyingArgument(given ctx: Context): Term = internal.Term_underlyingArgument(self) def underlying(given ctx: Context): Term = internal.Term_underlying(self) /** A unary apply node with given argument: `tree(arg)` */ def appliedTo(arg: Term)(given ctx: Context): Term = - appliedToArgs(arg :: Nil) + self.appliedToArgs(arg :: Nil) /** An apply node with given arguments: `tree(arg, args0, ..., argsN)` */ def appliedTo(arg: Term, args: Term*)(given ctx: Context): Term = - appliedToArgs(arg :: args.toList) + self.appliedToArgs(arg :: args.toList) /** An apply node with given argument list `tree(args(0), ..., args(args.length - 1))` */ def appliedToArgs(args: List[Term])(given ctx: Context): Apply = @@ -198,15 +192,16 @@ trait TreeOps extends Core { argss.foldLeft(self: Term)(Apply(_, _)) /** The current tree applied to (): `tree()` */ - def appliedToNone(given ctx: Context): Apply = appliedToArgs(Nil) + def appliedToNone(given ctx: Context): Apply = + self.appliedToArgs(Nil) /** The current tree applied to given type argument: `tree[targ]` */ def appliedToType(targ: Type)(given ctx: Context): Term = - appliedToTypes(targ :: Nil) + self.appliedToTypes(targ :: Nil) /** The current tree applied to given type arguments: `tree[targ0, ..., targN]` */ def appliedToTypes(targs: List[Type])(given ctx: Context): Term = - appliedToTypeTrees(targs map (Inferred(_))) + self.appliedToTypeTrees(targs map (Inferred(_))) /** The current tree applied to given type argument list: `tree[targs(0), ..., targs(targs.length - 1)]` */ def appliedToTypeTrees(targs: List[TypeTree])(given ctx: Context): Term = @@ -243,7 +238,7 @@ trait TreeOps extends Core { def unapply(tree: Tree)(given ctx: Context): Option[Ident] = internal.matchIdent(tree) } - implicit class IdentAPI(self: Ident) { + given (self: Ident) { def name(given ctx: Context): String = internal.Ident_name(self) } @@ -293,7 +288,7 @@ trait TreeOps extends Core { internal.matchSelect(tree).map(x => (x.qualifier, x.name)) } - implicit class SelectAPI(self: Select) { + given (self: Select) { def qualifier(given ctx: Context): Term = internal.Select_qualifier(self) def name(given ctx: Context): String = internal.Select_name(self) def signature(given ctx: Context): Option[Signature] = internal.Select_signature(self) @@ -319,7 +314,7 @@ trait TreeOps extends Core { internal.matchLiteral(tree).map(_.constant) } - implicit class LiteralAPI(self: Literal) { + given (self: Literal) { def constant(given ctx: Context): Constant = internal.Literal_constant(self) } @@ -344,7 +339,7 @@ trait TreeOps extends Core { } - implicit class ThisAPI(self: This) { + given (self: This) { def id(given ctx: Context): Option[Id] = internal.This_id(self) } @@ -368,7 +363,7 @@ trait TreeOps extends Core { internal.matchNew(tree).map(_.tpt) } - implicit class NewAPI(self: New) { + given (self: New) { def tpt(given ctx: Context): TypeTree = internal.New_tpt(self) } @@ -393,7 +388,7 @@ trait TreeOps extends Core { } - implicit class NamedArgAPI(self: NamedArg) { + given (self: NamedArg) { def name(given ctx: Context): String = internal.NamedArg_name(self) def value(given ctx: Context): Term = internal.NamedArg_value(self) } @@ -418,7 +413,7 @@ trait TreeOps extends Core { internal.matchApply(tree).map(x => (x.fun, x.args)) } - implicit class ApplyAPI(self: Apply) { + given (self: Apply) { def fun(given ctx: Context): Term = internal.Apply_fun(self) def args(given ctx: Context): List[Term] = internal.Apply_args(self) } @@ -445,7 +440,7 @@ trait TreeOps extends Core { } - implicit class TypeApplyAPI(self: TypeApply) { + given (self: TypeApply) { def fun(given ctx: Context): Term = internal.TypeApply_fun(self) def args(given ctx: Context): List[TypeTree] = internal.TypeApply_args(self) } @@ -470,7 +465,7 @@ trait TreeOps extends Core { internal.matchSuper(tree).map(x => (x.qualifier, x.id)) } - implicit class SuperAPI(self: Super) { + given (self: Super) { def qualifier(given ctx: Context): Term = internal.Super_qualifier(self) def id(given ctx: Context): Option[Id] = internal.Super_id(self) } @@ -496,7 +491,7 @@ trait TreeOps extends Core { } - implicit class TypedAPI(self: Typed) { + given (self: Typed) { def expr(given ctx: Context): Term = internal.Typed_expr(self) def tpt(given ctx: Context): TypeTree = internal.Typed_tpt(self) } @@ -521,7 +516,7 @@ trait TreeOps extends Core { internal.matchAssign(tree).map(x => (x.lhs, x.rhs)) } - implicit class AssignAPI(self: Assign) { + given (self: Assign) { def lhs(given ctx: Context): Term = internal.Assign_lhs(self) def rhs(given ctx: Context): Term = internal.Assign_rhs(self) } @@ -546,7 +541,7 @@ trait TreeOps extends Core { internal.matchBlock(tree).map(x => (x.statements, x.expr)) } - implicit class BlockAPI(self: Block) { + given (self: Block) { def statements(given ctx: Context): List[Statement] = internal.Block_statements(self) def expr(given ctx: Context): Term = internal.Block_expr(self) } @@ -568,7 +563,7 @@ trait TreeOps extends Core { internal.matchClosure(tree).map(x => (x.meth, x.tpeOpt)) } - implicit class ClosureAPI(self: Closure) { + given (self: Closure) { def meth(given ctx: Context): Term = internal.Closure_meth(self) def tpeOpt(given ctx: Context): Option[Type] = internal.Closure_tpeOpt(self) } @@ -616,7 +611,7 @@ trait TreeOps extends Core { } - implicit class IfAPI(self: If) { + given (self: If) { def cond(given ctx: Context): Term = internal.If_cond(self) def thenp(given ctx: Context): Term = internal.If_thenp(self) def elsep(given ctx: Context): Term = internal.If_elsep(self) @@ -643,7 +638,7 @@ trait TreeOps extends Core { } - implicit class MatchAPI(self: Match) { + given (self: Match) { def scrutinee(given ctx: Context): Term = internal.Match_scrutinee(self) def cases(given ctx: Context): List[CaseDef] = internal.Match_cases(self) } @@ -669,7 +664,7 @@ trait TreeOps extends Core { } - implicit class ImplicitMatchAPI(self: ImpliedMatch) { + given (self: ImpliedMatch) { def cases(given ctx: Context): List[CaseDef] = internal.ImplicitMatch_cases(self) } @@ -694,7 +689,7 @@ trait TreeOps extends Core { } - implicit class TryAPI(self: Try) { + given (self: Try) { def body(given ctx: Context): Term = internal.Try_body(self) def cases(given ctx: Context): List[CaseDef] = internal.Try_cases(self) def finalizer(given ctx: Context): Option[Term] = internal.Try_finalizer(self) @@ -721,7 +716,7 @@ trait TreeOps extends Core { } - implicit class ReturnAPI(self: Return) { + given (self: Return) { def expr(given ctx: Context): Term = internal.Return_expr(self) } @@ -743,7 +738,7 @@ trait TreeOps extends Core { } - implicit class RepeatedAPI(self: Repeated) { + given (self: Repeated) { def elems(given ctx: Context): List[Term] = internal.Repeated_elems(self) def elemtpt(given ctx: Context): TypeTree = internal.Repeated_elemtpt(self) } @@ -766,7 +761,7 @@ trait TreeOps extends Core { } - implicit class InlinedAPI(self: Inlined) { + given (self: Inlined) { def call(given ctx: Context): Option[Tree /* Term | TypeTree */] = internal.Inlined_call(self) def bindings(given ctx: Context): List[Definition] = internal.Inlined_bindings(self) def body(given ctx: Context): Term = internal.Inlined_body(self) @@ -790,10 +785,9 @@ trait TreeOps extends Core { } - implicit class SelectOuterAPI(self: SelectOuter) { + given (self: SelectOuter) { def qualifier(given ctx: Context): Term = internal.SelectOuter_qualifier(self) def level(given ctx: Context): Int = internal.SelectOuter_level(self) - def tpe(given ctx: Context): Type = internal.SelectOuter_tpe(self) } object IsWhile { @@ -816,22 +810,16 @@ trait TreeOps extends Core { } - implicit class WhileAPI(self: While) { + given (self: While) { def cond(given ctx: Context): Term = internal.While_cond(self) def body(given ctx: Context): Term = internal.While_body(self) } // ----- TypeTrees ------------------------------------------------ - implicit class TypeTreeAPI(self: TypeTree) { - /** Position in the source code */ - def pos(given ctx: Context): Position = internal.TypeTree_pos(self) - + given (self: TypeTree) { /** Type of this type tree */ def tpe(given ctx: Context): Type = internal.TypeTree_tpe(self) - - /** Symbol of this type tree */ - def symbol(given ctx: Context): Symbol = internal.TypeTree_symbol(self) } object IsTypeTree { @@ -860,7 +848,7 @@ trait TreeOps extends Core { internal.matchTypeIdent(tree) } - implicit class TypeIdentAPI(self: TypeIdent) { + given (self: TypeIdent) { def name(given ctx: Context): String = internal.TypeIdent_name(self) } @@ -887,7 +875,7 @@ trait TreeOps extends Core { internal.matchTypeSelect(tree).map(x => (x.qualifier, x.name)) } - implicit class TypeSelectAPI(self: TypeSelect) { + given (self: TypeSelect) { def qualifier(given ctx: Context): Term = internal.TypeSelect_qualifier(self) def name(given ctx: Context): String = internal.TypeSelect_name(self) } @@ -906,7 +894,7 @@ trait TreeOps extends Core { internal.matchProjection(tree).map(x => (x.qualifier, x.name)) } - implicit class ProjectionAPI(self: Projection) { + given (self: Projection) { def qualifier(given ctx: Context): TypeTree = internal.Projection_qualifier(self) def name(given ctx: Context): String = internal.Projection_name(self) } @@ -926,7 +914,7 @@ trait TreeOps extends Core { internal.matchSingleton(tree).map(_.ref) } - implicit class SingletonAPI(self: Singleton) { + given (self: Singleton) { def ref(given ctx: Context): Term = internal.Singleton_ref(self) } @@ -944,7 +932,7 @@ trait TreeOps extends Core { internal.matchRefined(tree).map(x => (x.tpt, x.refinements)) } - implicit class RefinedAPI(self: Refined) { + given (self: Refined) { def tpt(given ctx: Context): TypeTree = internal.Refined_tpt(self) def refinements(given ctx: Context): List[Definition] = internal.Refined_refinements(self) } @@ -964,7 +952,7 @@ trait TreeOps extends Core { internal.matchApplied(tree).map(x => (x.tpt, x.args)) } - implicit class AppliedAPI(self: Applied) { + given (self: Applied) { def tpt(given ctx: Context): TypeTree = internal.Applied_tpt(self) def args(given ctx: Context): List[Tree /*TypeTree | TypeBoundsTree*/] = internal.Applied_args(self) } @@ -984,7 +972,7 @@ trait TreeOps extends Core { internal.matchAnnotated(tree).map(x => (x.arg, x.annotation)) } - implicit class AnnotatedAPI(self: Annotated) { + given (self: Annotated) { def arg(given ctx: Context): TypeTree = internal.Annotated_arg(self) def annotation(given ctx: Context): Term = internal.Annotated_annotation(self) } @@ -1004,7 +992,7 @@ trait TreeOps extends Core { internal.matchMatchTypeTree(tree).map(x => (x.bound, x.selector, x.cases)) } - implicit class MatchTypeTreeAPI(self: MatchTypeTree) { + given (self: MatchTypeTree) { def bound(given ctx: Context): Option[TypeTree] = internal.MatchTypeTree_bound(self) def selector(given ctx: Context): TypeTree = internal.MatchTypeTree_selector(self) def cases(given ctx: Context): List[TypeCaseDef] = internal.MatchTypeTree_cases(self) @@ -1025,7 +1013,7 @@ trait TreeOps extends Core { internal.matchByName(tree).map(_.result) } - implicit class ByNameAPI(self: ByName) { + given (self: ByName) { def result(given ctx: Context): TypeTree = internal.ByName_result(self) } @@ -1044,7 +1032,7 @@ trait TreeOps extends Core { internal.matchLambdaTypeTree(tree).map(x => (x.tparams, x.body)) } - implicit class LambdaTypeTreeAPI(self: LambdaTypeTree) { + given (self: LambdaTypeTree) { def tparams(given ctx: Context): List[TypeDef] = internal.Lambdatparams(self) def body(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.Lambdabody(self) } @@ -1063,7 +1051,7 @@ trait TreeOps extends Core { internal.matchTypeBind(tree).map(x => (x.name, x.body)) } - implicit class TypeBindAPI(self: TypeBind) { + given (self: TypeBind) { def name(given ctx: Context): String = internal.TypeBind_name(self) def body(given ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = internal.TypeBind_body(self) } @@ -1083,14 +1071,14 @@ trait TreeOps extends Core { internal.matchTypeBlock(tree).map(x => (x.aliases, x.tpt)) } - implicit class TypeBlockAPI(self: TypeBlock) { + given (self: TypeBlock) { def aliases(given ctx: Context): List[TypeDef] = internal.TypeBlock_aliases(self) def tpt(given ctx: Context): TypeTree = internal.TypeBlock_tpt(self) } // ----- TypeBoundsTrees ------------------------------------------------ - implicit class TypeBoundsTreeAPI(self: TypeBoundsTree) { + given (self: TypeBoundsTree) { def tpe(given ctx: Context): TypeBounds = internal.TypeBoundsTree_tpe(self) def low(given ctx: Context): TypeTree = internal.TypeBoundsTree_low(self) def hi(given ctx: Context): TypeTree = internal.TypeBoundsTree_hi(self) @@ -1106,7 +1094,7 @@ trait TreeOps extends Core { internal.matchTypeBoundsTree(tree).map(x => (x.low, x.hi)) } - implicit class WildcardTypeTreeAPI(self: WildcardTypeTree) { + given (self: WildcardTypeTree) { def tpe(given ctx: Context): TypeOrBounds = internal.WildcardTypeTree_tpe(self) } @@ -1124,7 +1112,7 @@ trait TreeOps extends Core { // ----- CaseDefs ------------------------------------------------ - implicit class CaseDefAPI(caseDef: CaseDef) { + given (caseDef: CaseDef) { def pattern(given ctx: Context): Tree = internal.CaseDef_pattern(caseDef) def guard(given ctx: Context): Option[Term] = internal.CaseDef_guard(caseDef) def rhs(given ctx: Context): Term = internal.CaseDef_rhs(caseDef) @@ -1146,7 +1134,7 @@ trait TreeOps extends Core { internal.matchCaseDef(tree).map( x => (x.pattern, x.guard, x.rhs)) } - implicit class TypeCaseDefAPI(caseDef: TypeCaseDef) { + given (caseDef: TypeCaseDef) { def pattern(given ctx: Context): TypeTree = internal.TypeCaseDef_pattern(caseDef) def rhs(given ctx: Context): TypeTree = internal.TypeCaseDef_rhs(caseDef) } @@ -1182,7 +1170,7 @@ trait TreeOps extends Core { internal.matchTree_Bind(pattern).map(x => (x.name, x.pattern)) } - implicit class BindAPI(bind: Bind) { + given (bind: Bind) { def name(given ctx: Context): String = internal.Tree_Bind_name(bind) def pattern(given ctx: Context): Tree = internal.Tree_Bind_pattern(bind) } @@ -1200,7 +1188,7 @@ trait TreeOps extends Core { internal.matchTree_Unapply(pattern).map(x => (x.fun, x.implicits, x.patterns)) } - implicit class UnapplyAPI(unapply: Unapply) { + given (unapply: Unapply) { def fun(given ctx: Context): Term = internal.Tree_Unapply_fun(unapply) def implicits(given ctx: Context): List[Term] = internal.Tree_Unapply_implicits(unapply) def patterns(given ctx: Context): List[Tree] = internal.Tree_Unapply_patterns(unapply) @@ -1220,7 +1208,7 @@ trait TreeOps extends Core { internal.matchTree_Alternatives(pattern).map(_.patterns) } - implicit class AlternativesAPI(alternatives: Alternatives) { + given (alternatives: Alternatives) { def patterns(given ctx: Context): List[Tree] = internal.Tree_Alternatives_patterns(alternatives) } diff --git a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala index e6b440ce8676..032418ed6925 100644 --- a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala +++ b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala @@ -7,7 +7,7 @@ trait TypeOrBoundsOps extends Core { def typeOf[T: scala.quoted.Type]: Type - implicit class TypeAPI(self: Type) { + given (self: Type) { def =:=(that: Type)(given ctx: Context): Boolean = internal.`Type_=:=`(self)(that) def <:<(that: Type)(given ctx: Context): Boolean = internal.`Type_<:<`(self)(that) def widen(given ctx: Context): Type = internal.Type_widen(self) @@ -276,79 +276,79 @@ trait TypeOrBoundsOps extends Core { } - implicit class Type_ConstantTypeAPI(self: ConstantType) { + given (self: ConstantType) { def constant(given ctx: Context): Constant = internal.ConstantType_constant(self) } - implicit class Type_TermRefAPI(self: TermRef) { + given (self: TermRef) { def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TermRef_qualifier(self) def name(given ctx: Context): String = internal.TermRef_name(self) } - implicit class Type_TypeRefAPI(self: TypeRef) { + given (self: TypeRef) { def qualifier(given ctx: Context): TypeOrBounds /* Type | NoPrefix */ = internal.TypeRef_qualifier(self) def name(given ctx: Context): String = internal.TypeRef_name(self) } - implicit class Type_SuperTypeAPI(self: SuperType) { + given (self: SuperType) { def thistpe(given ctx: Context): Type = internal.SuperType_thistpe(self) def supertpe(given ctx: Context): Type = internal.SuperType_supertpe(self) } - implicit class Type_RefinementAPI(self: Refinement) { + given (self: Refinement) { def parent(given ctx: Context): Type = internal.Refinement_parent(self) def name(given ctx: Context): String = internal.Refinement_name(self) def info(given ctx: Context): TypeOrBounds = internal.Refinement_info(self) } - implicit class Type_AppliedTypeAPI(self: AppliedType) { + given (self: AppliedType) { def tycon(given ctx: Context): Type = internal.AppliedType_tycon(self) def args(given ctx: Context): List[TypeOrBounds /* Type | TypeBounds */] = internal.AppliedType_args(self) } - implicit class Type_AnnotatedTypeAPI(self: AnnotatedType) { + given (self: AnnotatedType) { def underlying(given ctx: Context): Type = internal.AnnotatedType_underlying(self) def annot(given ctx: Context): Term = internal.AnnotatedType_annot(self) } - implicit class Type_AndTypeAPI(self: AndType) { + given (self: AndType) { def left(given ctx: Context): Type = internal.AndType_left(self) def right(given ctx: Context): Type = internal.AndType_right(self) } - implicit class Type_OrTypeAPI(self: OrType) { + given (self: OrType) { def left(given ctx: Context): Type = internal.OrType_left(self) def right(given ctx: Context): Type = internal.OrType_right(self) } - implicit class Type_MatchTypeAPI(self: MatchType) { + given (self: MatchType) { def bound(given ctx: Context): Type = internal.MatchType_bound(self) def scrutinee(given ctx: Context): Type = internal.MatchType_scrutinee(self) def cases(given ctx: Context): List[Type] = internal.MatchType_cases(self) } - implicit class Type_ByNameTypeAPI(self: ByNameType) { + given (self: ByNameType) { def underlying(given ctx: Context): Type = internal.ByNameType_underlying(self) } - implicit class Type_ParamRefAPI(self: ParamRef) { + given (self: ParamRef) { def binder(given ctx: Context): LambdaType[TypeOrBounds] = internal.ParamRef_binder(self) def paramNum(given ctx: Context): Int = internal.ParamRef_paramNum(self) } - implicit class Type_ThisTypeAPI(self: ThisType) { + given (self: ThisType) { def tref(given ctx: Context): Type = internal.ThisType_tref(self) } - implicit class Type_RecursiveThisAPI(self: RecursiveThis) { + given (self: RecursiveThis) { def binder(given ctx: Context): RecursiveType = internal.RecursiveThis_binder(self) } - implicit class Type_RecursiveTypeAPI(self: RecursiveType) { + given (self: RecursiveType) { def underlying(given ctx: Context): Type = internal.RecursiveType_underlying(self) } - implicit class Type_MethodTypeAPI(self: MethodType) { + given (self: MethodType) { def isImplicit: Boolean = internal.MethodType_isImplicit(self) def isErased: Boolean = internal.MethodType_isErased(self) def paramNames(given ctx: Context): List[String] = internal.MethodType_paramNames(self) @@ -356,13 +356,13 @@ trait TypeOrBoundsOps extends Core { def resType(given ctx: Context): Type = internal.MethodType_resType(self) } - implicit class Type_PolyTypeAPI(self: PolyType) { + given (self: PolyType) { def paramNames(given ctx: Context): List[String] = internal.PolyType_paramNames(self) def paramBounds(given ctx: Context): List[TypeBounds] = internal.PolyType_paramBounds(self) def resType(given ctx: Context): Type = internal.PolyType_resType(self) } - implicit class Type_TypeLambdaAPI(self: TypeLambda) { + given (self: TypeLambda) { def paramNames(given ctx: Context): List[String] = internal.TypeLambda_paramNames(self) def paramBounds(given ctx: Context): List[TypeBounds] = internal.TypeLambda_paramBounds(self) def resType(given ctx: Context): Type = internal.TypeLambda_resType(self) @@ -380,7 +380,7 @@ trait TypeOrBoundsOps extends Core { internal.matchTypeBounds(typeOrBounds).map(x => (x.low, x.hi)) } - implicit class TypeBoundsAPI(self: TypeBounds) { + given (self: TypeBounds) { def low(given ctx: Context): Type = internal.TypeBounds_low(self) def hi(given ctx: Context): Type = internal.TypeBounds_hi(self) } diff --git a/tests/neg-macros/delegate-match-1/Macro_1.scala b/tests/neg-macros/delegate-match-1/Macro_1.scala index 7e94cd5e4cc5..2a4dc426d9d1 100644 --- a/tests/neg-macros/delegate-match-1/Macro_1.scala +++ b/tests/neg-macros/delegate-match-1/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } private def fImpl(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} searchImplicit(('[A]).unseal.tpe) match { case IsImplicitSearchSuccess(x) => '{} diff --git a/tests/neg-macros/delegate-match-2/Macro_1.scala b/tests/neg-macros/delegate-match-2/Macro_1.scala index 7e94cd5e4cc5..2a4dc426d9d1 100644 --- a/tests/neg-macros/delegate-match-2/Macro_1.scala +++ b/tests/neg-macros/delegate-match-2/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } private def fImpl(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} searchImplicit(('[A]).unseal.tpe) match { case IsImplicitSearchSuccess(x) => '{} diff --git a/tests/neg-macros/delegate-match-3/Macro_1.scala b/tests/neg-macros/delegate-match-3/Macro_1.scala index 7e94cd5e4cc5..2a4dc426d9d1 100644 --- a/tests/neg-macros/delegate-match-3/Macro_1.scala +++ b/tests/neg-macros/delegate-match-3/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.matching._ inline def f: Any = ${ fImpl } private def fImpl(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} searchImplicit(('[A]).unseal.tpe) match { case IsImplicitSearchSuccess(x) => '{} diff --git a/tests/neg-macros/i6432/Macro_1.scala b/tests/neg-macros/i6432/Macro_1.scala index 3f209c0d84f5..501926e3537c 100644 --- a/tests/neg-macros/i6432/Macro_1.scala +++ b/tests/neg-macros/i6432/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def (sc: => StringContext) foo (args: String*): Unit = ${ impl('sc) } def impl(sc: Expr[StringContext])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} sc match { case '{ StringContext(${ExprSeq(parts)}: _*) } => for (part @ Const(s) <- parts) diff --git a/tests/neg-macros/i6432b/Macro_1.scala b/tests/neg-macros/i6432b/Macro_1.scala index 3f209c0d84f5..501926e3537c 100644 --- a/tests/neg-macros/i6432b/Macro_1.scala +++ b/tests/neg-macros/i6432b/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def (sc: => StringContext) foo (args: String*): Unit = ${ impl('sc) } def impl(sc: Expr[StringContext])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} sc match { case '{ StringContext(${ExprSeq(parts)}: _*) } => for (part @ Const(s) <- parts) diff --git a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala index 37eb2991d611..2dd494550bf9 100644 --- a/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-1/quoted_1.scala @@ -13,7 +13,7 @@ object Asserts { ${impl('cond)} def impl(cond: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = cond.unseal diff --git a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala index 68b65994b3c5..9acb12908090 100644 --- a/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-assert-2/quoted_1.scala @@ -13,7 +13,7 @@ object Asserts { ${ impl('cond) } def impl(cond: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = cond.unseal diff --git a/tests/neg-macros/tasty-macro-error/quoted_1.scala b/tests/neg-macros/tasty-macro-error/quoted_1.scala index 8e2ee6cb9f15..69189cd220d1 100644 --- a/tests/neg-macros/tasty-macro-error/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-error/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def fun(x: Any): Unit = ${ impl('x) } def impl(x: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} error("here is the the argument is " + x.unseal.underlyingArgument.show, x.unseal.underlyingArgument.pos) '{} } diff --git a/tests/neg-macros/tasty-macro-positions/quoted_1.scala b/tests/neg-macros/tasty-macro-positions/quoted_1.scala index b5d5b88c188f..729ffe652955 100644 --- a/tests/neg-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/neg-macros/tasty-macro-positions/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def fun(x: Any): Unit = ${ impl('x) } def impl(x: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val pos = x.unseal.underlyingArgument.pos error("here is the the argument is " + x.unseal.underlyingArgument.show, pos) error("here (+5) is the the argument is " + x.unseal.underlyingArgument.show, pos.sourceFile, pos.start + 5, pos.end + 5) diff --git a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala index 67e67d0898ac..bf05adc5122d 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala @@ -10,7 +10,7 @@ object Macro { object FIntepolator { def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos) '{ ($strCtxExpr).s($argsExpr: _*) } } diff --git a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala index 224387a842a4..a4de659aee3d 100644 --- a/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala +++ b/tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala @@ -9,7 +9,7 @@ object Macro { object FIntepolator { def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} error("there are no args", argsExpr.unseal.underlyingArgument.pos) '{ ($strCtxExpr).s($argsExpr: _*) } } diff --git a/tests/neg-staging/i5941/macro_1.scala b/tests/neg-staging/i5941/macro_1.scala index ada64cf018b1..5ec3d910df6a 100644 --- a/tests/neg-staging/i5941/macro_1.scala +++ b/tests/neg-staging/i5941/macro_1.scala @@ -13,7 +13,7 @@ object Lens { def impl[S: Type, T: Type](getter: Expr[S => T])(given qctx: QuoteContext): Expr[Lens[S, T]] = { implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(this.getClass.getClassLoader) - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ // obj.copy(field = value) def setterBody(obj: Expr[S], value: Expr[T], field: String): Expr[S] = diff --git a/tests/pending/run/tasty-comments/quoted_1.scala b/tests/pending/run/tasty-comments/quoted_1.scala index b14303b85ffe..f593b7b5ed19 100644 --- a/tests/pending/run/tasty-comments/quoted_1.scala +++ b/tests/pending/run/tasty-comments/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { ${ impl('t) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = x.unseal tree.symbol.comment.map(_.raw) match { diff --git a/tests/pos-macros/i6171/Macro_1.scala b/tests/pos-macros/i6171/Macro_1.scala index abea0582b709..01826821a80f 100644 --- a/tests/pos-macros/i6171/Macro_1.scala +++ b/tests/pos-macros/i6171/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(x: => Any): Unit = ${ assertImpl('x) } def assertImpl(x: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} x.unseal.underlyingArgument '{ () } } diff --git a/tests/pos-macros/i6535/Macro_1.scala b/tests/pos-macros/i6535/Macro_1.scala index c52eca82b968..619197c61c9b 100644 --- a/tests/pos-macros/i6535/Macro_1.scala +++ b/tests/pos-macros/i6535/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) } def assertImpl(cond: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ cond.unseal.underlyingArgument match { diff --git a/tests/pos-macros/i6803b/Macro_1.scala b/tests/pos-macros/i6803b/Macro_1.scala index 815b457ec8ee..99dd47c0513c 100644 --- a/tests/pos-macros/i6803b/Macro_1.scala +++ b/tests/pos-macros/i6803b/Macro_1.scala @@ -10,7 +10,7 @@ object AsObject { def unsafe(i: Int): LineNo = new LineNo(i) inline given x : LineNo = ${impl} private def impl(given qctx: QuoteContext): Expr[LineNo] = { - import qctx.tasty._ + import qctx.tasty.{_, given} '{unsafe(${rootPosition.startLine})} } } diff --git a/tests/pos-macros/i7011/Macros_1.scala b/tests/pos-macros/i7011/Macros_1.scala index 21c0730bb85a..2bdd8661da65 100644 --- a/tests/pos-macros/i7011/Macros_1.scala +++ b/tests/pos-macros/i7011/Macros_1.scala @@ -4,7 +4,7 @@ import scala.quoted.given inline def mcr(body: => Any): Unit = ${mcrImpl('body)} def mcrImpl[T](body: Expr[Any])(given ctx: QuoteContext): Expr[Any] = { - import ctx.tasty._ + import ctx.tasty.{_, given} val bTree = body.unseal val under = bTree.underlyingArgument diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index 79ff95da7a99..e78f61ce7ca8 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def ff[A <: Int, B <: Int]() <: AddInt[A, B] = ${ impl('[A], '[B]) } def impl[A <: Int : Type, B <: Int : Type](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[AddInt[A, B]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val Type.ConstantType(Constant(v1: Int)) = a.unseal.tpe val Type.ConstantType(Constant(v2: Int)) = b.unseal.tpe diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index b68ff003b267..859c404dd3d6 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -7,7 +7,7 @@ object Foo { ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} x.unseal match { case Inlined(None, Nil, arg) => arg.symbol.tree.showExtractors case arg => arg.symbol.tree.showExtractors // TODO should all by name parameters be in an inline node? diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index 4fc2489292d9..523966bf435b 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -7,7 +7,7 @@ object Foo { ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} x.unseal match { case Inlined(None, Nil, arg) => arg.symbol.tree.showExtractors case arg => arg.symbol.tree.showExtractors // TODO should all by name parameters be in an inline node? diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 05d93618f0af..ab6f853cb7ab 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { ${ impl('x) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val buff = new StringBuilder diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index dfd1276ab31c..35623f76e564 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -7,7 +7,7 @@ object Foo { ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def definitionString(sym: Symbol): Expr[String] = if sym.isClassDef || sym.isDefDef || sym.isValDef then Expr(sym.tree.showExtractors) diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index d87d0de9e073..59b19ed56828 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -6,7 +6,7 @@ object Foo { ${ inspectBodyImpl('i) } def inspectBodyImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def definitionString(sym: Symbol): Expr[String] = if sym.isClassDef || sym.isDefDef || sym.isValDef then Expr(sym.tree.showExtractors) diff --git a/tests/run-macros/f-interpolation-1/FQuote_1.scala b/tests/run-macros/f-interpolation-1/FQuote_1.scala index 9ce0a5c32900..cfa888ac01b7 100644 --- a/tests/run-macros/f-interpolation-1/FQuote_1.scala +++ b/tests/run-macros/f-interpolation-1/FQuote_1.scala @@ -10,7 +10,7 @@ object FQuote { } /*private*/ def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def liftListOfAny(lst: List[Term]): Expr[List[Any]] = lst match { case x :: xs => diff --git a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala index 52d3c3b09dd1..b51e450fab04 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -7,28 +7,28 @@ object TypeToolbox { /** are the two types equal? */ inline def =:=[A, B]: Boolean = ${tpEqImpl('[A], '[B])} private def tpEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(a.unseal.tpe =:= b.unseal.tpe) } /** is `tp1` a subtype of `tp2` */ inline def <:<[A, B]: Boolean = ${tpLEqImpl('[A], '[B])} private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(a.unseal.tpe <:< b.unseal.tpe) } /** type associated with the tree */ inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('a, '[Expected])} private def typeOfImpl(a: Expr[_], expected: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(a.unseal.tpe =:= expected.unseal.tpe) } /** does the type refer to a case class? */ inline def isCaseClass[A]: Boolean = ${isCaseClassImpl('[A])} private def isCaseClassImpl(tp: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val sym = tp.unseal.symbol Expr(sym.isClassDef && sym.flags.is(Flags.Case)) } @@ -36,66 +36,66 @@ object TypeToolbox { /** val fields of a case class Type -- only the ones declared in primary constructor */ inline def caseFields[T]: List[String] = ${caseFieldsImpl('[T])} private def caseFieldsImpl(tp: Type[_])(given qctx: QuoteContext): Expr[List[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val fields = tp.unseal.symbol.caseFields.map(_.name) Expr(fields) } inline def fieldIn[T](inline mem: String): String = ${fieldInImpl('[T], mem)} private def fieldInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val field = t.unseal.symbol.field(mem) Expr(if field.isNoSymbol then "" else field.name) } inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl('[T])} private def fieldsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val fields = t.unseal.symbol.fields Expr(fields.map(_.name).toList) } inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl('[T], mem)} private def methodInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(t.unseal.symbol.classMethod(mem).map(_.name)) } inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} private def methodsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(t.unseal.symbol.classMethods.map(_.name)) } inline def method[T](inline mem: String): Seq[String] = ${methodImpl('[T], mem)} private def methodImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(t.unseal.symbol.method(mem).map(_.name)) } inline def methods[T]: Seq[String] = ${methodsImpl('[T])} private def methodsImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(t.unseal.symbol.methods.map(_.name)) } inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} private def typeTagImpl(tp: Type[_])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val res = tp.unseal.tpe.show Expr(res) } inline def companion[T1, T2]: Boolean = ${companionImpl('[T1], '[T2])} private def companionImpl(t1: Type[_], t2: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val res = t1.unseal.symbol.companionModule == t2.unseal.symbol Expr(res) } inline def companionName[T1]: String = ${companionNameImpl('[T1])} private def companionNameImpl(tp: Type[_])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val sym = tp.unseal.symbol val companionClass = if sym.isClassDef then sym.companionModule.companionClass diff --git a/tests/run-macros/i5119/Macro_1.scala b/tests/run-macros/i5119/Macro_1.scala index 05f4434d0f39..d143c9b90164 100644 --- a/tests/run-macros/i5119/Macro_1.scala +++ b/tests/run-macros/i5119/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { } implicit inline def XmlQuote(sc: => StringContext): StringContextOps = new StringContextOps(sc) def impl(sc: Expr[StringContext], args: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} (sc.unseal.underlyingArgument.showExtractors + "\n" + args.unseal.underlyingArgument.showExtractors) } } diff --git a/tests/run-macros/i5119b/Macro_1.scala b/tests/run-macros/i5119b/Macro_1.scala index 629955cdee0e..399ddfd68f3c 100644 --- a/tests/run-macros/i5119b/Macro_1.scala +++ b/tests/run-macros/i5119b/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def ff(arg1: Any, arg2: Any): String = ${ Macro.impl('{arg1}, '{arg2}) } def impl(arg1: Expr[Any], arg2: Expr[Any])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} (arg1.unseal.underlyingArgument.showExtractors + "\n" + arg2.unseal.underlyingArgument.showExtractors) } diff --git a/tests/run-macros/i5533/Macro_1.scala b/tests/run-macros/i5533/Macro_1.scala index 10f5d6ec0a64..f5c3f62b689c 100644 --- a/tests/run-macros/i5533/Macro_1.scala +++ b/tests/run-macros/i5533/Macro_1.scala @@ -8,7 +8,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = condition.unseal diff --git a/tests/run-macros/i5533b/Macro_1.scala b/tests/run-macros/i5533b/Macro_1.scala index 6459758bf764..3a986a9ed021 100644 --- a/tests/run-macros/i5533b/Macro_1.scala +++ b/tests/run-macros/i5533b/Macro_1.scala @@ -7,7 +7,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = condition.unseal def exprStr: String = condition.show diff --git a/tests/run-macros/i5536/Macro_1.scala b/tests/run-macros/i5536/Macro_1.scala index 3c55be4f1ded..c4e1f9acb861 100644 --- a/tests/run-macros/i5536/Macro_1.scala +++ b/tests/run-macros/i5536/Macro_1.scala @@ -4,7 +4,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)} def assertImpl(condition: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = condition.unseal def exprStr: String = condition.show diff --git a/tests/run-macros/i5629/Macro_1.scala b/tests/run-macros/i5629/Macro_1.scala index cf7a6306f336..67e5af217012 100644 --- a/tests/run-macros/i5629/Macro_1.scala +++ b/tests/run-macros/i5629/Macro_1.scala @@ -5,7 +5,7 @@ object Macros { inline def assert(condition: => Boolean): Unit = ${ assertImpl('{condition}, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val b = cond.unseal.underlyingArgument.seal.cast[Boolean] '{ scala.Predef.assert($b) } } @@ -13,7 +13,7 @@ object Macros { inline def thisLineNumber = ${ thisLineNumberImpl } def thisLineNumberImpl(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(rootPosition.startLine) } } diff --git a/tests/run-macros/i5715/Macro_1.scala b/tests/run-macros/i5715/Macro_1.scala index 556a14493049..0eea998edf3b 100644 --- a/tests/run-macros/i5715/Macro_1.scala +++ b/tests/run-macros/i5715/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} cond.unseal.underlyingArgument match { case app @ Apply(sel @ Select(lhs, op), rhs :: Nil) => diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index a7c3fc8609c0..ff41ce1a77ab 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -12,7 +12,7 @@ object Lens { } def impl[S: Type, T: Type](getter: Expr[S => T])(given qctx: QuoteContext): Expr[Lens[S, T]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ // obj.copy(a = obj.a.copy(b = a.b.copy(c = v))) @@ -85,7 +85,7 @@ object Iso { } def impl[S: Type, A: Type](given qctx: QuoteContext): Expr[Iso[S, A]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ val tpS = typeOf[S] @@ -124,7 +124,7 @@ object Iso { } def implUnit[S: Type](given qctx: QuoteContext): Expr[Iso[S, 1]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ val tpS = typeOf[S] @@ -196,7 +196,7 @@ object Prism { } def impl[S: Type, A <: S : Type](given qctx: QuoteContext): Expr[Prism[S, A]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ '{ diff --git a/tests/run-macros/i6171/Macro_1.scala b/tests/run-macros/i6171/Macro_1.scala index e4ea2214ca4c..729acd0d5d59 100644 --- a/tests/run-macros/i6171/Macro_1.scala +++ b/tests/run-macros/i6171/Macro_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala index 3a780da9ba54..f513ef6c7bd0 100644 --- a/tests/run-macros/i6518/Macro_1.scala +++ b/tests/run-macros/i6518/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { inline def test(): String = ${ testImpl } private def testImpl(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val classSym = typeOf[Function1[_, _]].classSymbol.get classSym.classMethod("apply") classSym.classMethods diff --git a/tests/run-macros/i6679/Macro_1.scala b/tests/run-macros/i6679/Macro_1.scala index a0291b848c59..06a95ac798cd 100644 --- a/tests/run-macros/i6679/Macro_1.scala +++ b/tests/run-macros/i6679/Macro_1.scala @@ -1,7 +1,7 @@ import scala.quoted._ def makeMatch[A: Type](head : Expr[A])(given qctx : QuoteContext) : Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val sacrifice = '{ $head match { case _ => ??? } } sacrifice.unseal diff --git a/tests/run-macros/i6765/Macro_1.scala b/tests/run-macros/i6765/Macro_1.scala index fcce12c14909..ba896209b190 100644 --- a/tests/run-macros/i6765/Macro_1.scala +++ b/tests/run-macros/i6765/Macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted.given inline def foo = ${fooImpl} def fooImpl(given qctx: QuoteContext) = { - import qctx.tasty._ + import qctx.tasty.{_, given} val res = Expr.ofList(List('{"One"})) Expr(res.show) } diff --git a/tests/run-macros/inferred-repeated-result/test_1.scala b/tests/run-macros/inferred-repeated-result/test_1.scala index 6bb84d5ab4a6..b9c4f7a36b6e 100644 --- a/tests/run-macros/inferred-repeated-result/test_1.scala +++ b/tests/run-macros/inferred-repeated-result/test_1.scala @@ -4,7 +4,7 @@ object Macros { inline def go[T](t: => T) = ${ impl('t) } def impl[T](expr: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = expr.unseal diff --git a/tests/run-macros/no-symbol/1.scala b/tests/run-macros/no-symbol/1.scala index 935a96a9aed3..fe7c219f7f80 100644 --- a/tests/run-macros/no-symbol/1.scala +++ b/tests/run-macros/no-symbol/1.scala @@ -8,8 +8,8 @@ object Macro { inline def foo[T](implicit inline t: Type[T]): String = ${ fooImpl } - def fooImpl[T](implicit t: Type[T], q: QuoteContext): Expr[String] = { - import q.tasty._ + def fooImpl[T](implicit t: Type[T], qctx: QuoteContext): Expr[String] = { + import qctx.tasty.{_, given} val sym = t.unseal.symbol if sym.isClassDef then '{ "symbol" } else if sym.isNoSymbol then '{ "no symbol" } diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala index 805d37f8bf3b..74ae1c224b72 100644 --- a/tests/run-macros/quote-inline-function/quoted_1.scala +++ b/tests/run-macros/quote-inline-function/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { inline def foreach2(start: Int, end: Int, f: => Int => Unit): String = ${impl('start, 'end, 'f)} def impl(start: Expr[Int], end: Expr[Int], f: Expr[Int => Unit])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val res = '{ var i = $start val j = $end diff --git a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala index 99a9598d912e..ec5c1a948dc1 100644 --- a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala @@ -20,7 +20,7 @@ object Macros { '{ $sym.times(${lift(x)}, ${lift(y)}) } case _ => - import qctx.tasty._ + import qctx.tasty.{_, given} error("Expected explicit DSL", e.unseal.pos) '{ ??? } diff --git a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala index 3bf4591b72c8..6e80bdf92422 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -26,7 +26,7 @@ object Macros { case Sym(b) if env.contains(b) => env(b) case _ => - import qctx.tasty._ + import qctx.tasty.{_, given} error("Expected explicit DSL", e.unseal.pos) ??? } @@ -36,7 +36,7 @@ object Macros { sym.lam((y: Expr[T]) => lift(body)(env + (x -> y))) case _ => - import qctx.tasty._ + import qctx.tasty.{_, given} error("Expected explicit DSL => DSL", e.unseal.pos) ??? } diff --git a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala index 78c62896a046..58df1397e20e 100644 --- a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala +++ b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala @@ -4,7 +4,7 @@ object Macro { inline def t2[T0, T1](t0: T0, t1: T1): (T0, T1) = ${ impl2('{t0}, '{t1}) } def impl2[T0: Type, T1: Type](t0: Expr[T0], t1: Expr[T1])(given qctx: QuoteContext): Expr[(T0, T1)] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ val seq = List(t0, t1) diff --git a/tests/run-macros/reflect-dsl/assert_1.scala b/tests/run-macros/reflect-dsl/assert_1.scala index a587b9432cbc..d063cf16d1e8 100644 --- a/tests/run-macros/reflect-dsl/assert_1.scala +++ b/tests/run-macros/reflect-dsl/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/reflect-isFunctionType/macro_1.scala b/tests/run-macros/reflect-isFunctionType/macro_1.scala index dd42f983d8e7..bf2dcbde9492 100644 --- a/tests/run-macros/reflect-isFunctionType/macro_1.scala +++ b/tests/run-macros/reflect-isFunctionType/macro_1.scala @@ -4,7 +4,7 @@ import scala.quoted._ inline def isFunctionType[T:Type]: Boolean = ${ isFunctionTypeImpl('[T]) } def isFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isFunctionType) } @@ -12,7 +12,7 @@ def isFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] inline def isImplicitFunctionType[T:Type]: Boolean = ${ isImplicitFunctionTypeImpl('[T]) } def isImplicitFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isImplicitFunctionType) } @@ -20,14 +20,14 @@ def isImplicitFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[B inline def isErasedFunctionType[T:Type]: Boolean = ${ isErasedFunctionTypeImpl('[T]) } def isErasedFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isErasedFunctionType) } inline def isDependentFunctionType[T:Type]: Boolean = ${ isDependentFunctionTypeImpl('[T]) } def isDependentFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isDependentFunctionType) } diff --git a/tests/run-macros/reflect-lambda/assert_1.scala b/tests/run-macros/reflect-lambda/assert_1.scala index 91d8f158ec1d..6743eb412b57 100644 --- a/tests/run-macros/reflect-lambda/assert_1.scala +++ b/tests/run-macros/reflect-lambda/assert_1.scala @@ -5,7 +5,7 @@ object lib { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ cond.unseal.underlyingArgument match { diff --git a/tests/run-macros/reflect-pos-fun/assert_1.scala b/tests/run-macros/reflect-pos-fun/assert_1.scala index e301efde9f7f..c6902daafd46 100644 --- a/tests/run-macros/reflect-pos-fun/assert_1.scala +++ b/tests/run-macros/reflect-pos-fun/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) } def assertImpl(cond: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ cond.unseal.underlyingArgument match { diff --git a/tests/run-macros/reflect-select-constructor/assert_1.scala b/tests/run-macros/reflect-select-constructor/assert_1.scala index 703e2d2e4252..0177198e6aef 100644 --- a/tests/run-macros/reflect-select-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-constructor/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/reflect-select-copy/assert_1.scala b/tests/run-macros/reflect-select-copy/assert_1.scala index 9b7777fcd4cd..03a9e8ccede2 100644 --- a/tests/run-macros/reflect-select-copy/assert_1.scala +++ b/tests/run-macros/reflect-select-copy/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} cond.unseal.underlyingArgument match { case Apply(sel @ Select(lhs, op), rhs :: Nil) => diff --git a/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala b/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala index d99f5c1d84c1..d428ede4c8cf 100644 --- a/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala +++ b/tests/run-macros/reflect-select-copy/reflect-select-copy/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala index ee799dce1e98..a6de05000b75 100644 --- a/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala +++ b/tests/run-macros/reflect-select-symbol-constructor/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/reflect-select-value-class/assert_1.scala b/tests/run-macros/reflect-select-value-class/assert_1.scala index 703e2d2e4252..0177198e6aef 100644 --- a/tests/run-macros/reflect-select-value-class/assert_1.scala +++ b/tests/run-macros/reflect-select-value-class/assert_1.scala @@ -5,7 +5,7 @@ object scalatest { inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition, '{""}) } def assertImpl(cond: Expr[Boolean], clue: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} import util._ def isImplicitMethodType(tp: Type): Boolean = diff --git a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala index 3938f30f0771..b97e966eef3f 100644 --- a/tests/run-macros/tasty-argument-tree-1/quoted_1.scala +++ b/tests/run-macros/tasty-argument-tree-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def inspect[T](x: T): Unit = ${ impl('x) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = x.unseal '{ println() diff --git a/tests/run-macros/tasty-custom-show/quoted_1.scala b/tests/run-macros/tasty-custom-show/quoted_1.scala index aefdbbf79c9d..df583d22da7e 100644 --- a/tests/run-macros/tasty-custom-show/quoted_1.scala +++ b/tests/run-macros/tasty-custom-show/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { ${ impl('x) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val buff = new StringBuilder @@ -38,9 +38,10 @@ object Macros { '{print(${buff.result()})} } - def dummyShow(given qctx: QuoteContext): qctx.tasty.Printer = { - import qctx.tasty._ - new Printer { + def dummyShow(given qctx: QuoteContext): scala.tasty.reflect.Printers[qctx.tasty.type]#Printer = { + import qctx.tasty.{_, given} + val printers = new scala.tasty.reflect.Printers(qctx.tasty) + new printers.Printer { def showTree(tree: Tree)(implicit ctx: Context): String = "Tree" def showTypeOrBounds(tpe: TypeOrBounds)(implicit ctx: Context): String = "TypeOrBounds" def showConstant(const: Constant)(implicit ctx: Context): String = "Constant" diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index 24a8dfaf9efd..86a6a05cf03f 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def dealias[T]: String = ${ impl('[T]) } def impl[T](x: quoted.Type[T])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(x.unseal.tpe.dealias.show) } } diff --git a/tests/run-macros/tasty-definitions-1/quoted_1.scala b/tests/run-macros/tasty-definitions-1/quoted_1.scala index 316c06a98724..9906b5790142 100644 --- a/tests/run-macros/tasty-definitions-1/quoted_1.scala +++ b/tests/run-macros/tasty-definitions-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def testDefinitions(): Unit = ${testDefinitionsImpl} def testDefinitionsImpl(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val buff = List.newBuilder[String] def printout(x: => String): Unit = { diff --git a/tests/run-macros/tasty-eval/quoted_1.scala b/tests/run-macros/tasty-eval/quoted_1.scala index 5903478f7db4..e639602a6600 100644 --- a/tests/run-macros/tasty-eval/quoted_1.scala +++ b/tests/run-macros/tasty-eval/quoted_1.scala @@ -18,7 +18,7 @@ object Macros { implicit def intIsEvalable: Valuable[Int] = new Valuable[Int] { override def value(e: Expr[Int])(given qctx: QuoteContext): Option[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} e.unseal.tpe match { case Type.IsTermRef(pre) if pre.termSymbol.isValDef => diff --git a/tests/run-macros/tasty-extractors-1/quoted_1.scala b/tests/run-macros/tasty-extractors-1/quoted_1.scala index 705ca60dfda7..87b1a3452a08 100644 --- a/tests/run-macros/tasty-extractors-1/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-1/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { ${ impl('x) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = x.unseal val treeStr = tree.showExtractors diff --git a/tests/run-macros/tasty-extractors-2/quoted_1.scala b/tests/run-macros/tasty-extractors-2/quoted_1.scala index 965b1c793100..e4683a928b28 100644 --- a/tests/run-macros/tasty-extractors-2/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-2/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { ${ impl('x) } def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = x.unseal diff --git a/tests/run-macros/tasty-extractors-3/quoted_1.scala b/tests/run-macros/tasty-extractors-3/quoted_1.scala index 59e9ede8271a..8f3f4f414371 100644 --- a/tests/run-macros/tasty-extractors-3/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-3/quoted_1.scala @@ -8,7 +8,7 @@ object Macros { ${impl('x)} def impl[T](x: Expr[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val buff = new StringBuilder val traverser = new TreeTraverser { diff --git a/tests/run-macros/tasty-extractors-types/quoted_1.scala b/tests/run-macros/tasty-extractors-types/quoted_1.scala index 7478ba18728c..3b1f76337bea 100644 --- a/tests/run-macros/tasty-extractors-types/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-types/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { implicit inline def printType[T]: Unit = ${ impl('[T]) } def impl[T](x: Type[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = x.unseal '{ diff --git a/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala b/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala index 1c47a0a53a4b..f325afd34277 100644 --- a/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala +++ b/tests/run-macros/tasty-getfile-implicit-fun-context/Macro_1.scala @@ -11,9 +11,8 @@ object SourceFiles { def getThisFileImpl: Macro[String] = { val qctx = tastyContext - import qctx.tasty._ + import qctx.tasty.{_, given} rootContext.source.getFileName.toString } - } diff --git a/tests/run-macros/tasty-getfile/Macro_1.scala b/tests/run-macros/tasty-getfile/Macro_1.scala index 06ec28b3dbd7..47947f67f36b 100644 --- a/tests/run-macros/tasty-getfile/Macro_1.scala +++ b/tests/run-macros/tasty-getfile/Macro_1.scala @@ -8,7 +8,7 @@ object SourceFiles { ${getThisFileImpl} private def getThisFileImpl(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} rootContext.source.getFileName.toString } diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 82e693c5b9db..bae6fbf00040 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -26,7 +26,7 @@ object Index { implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${succImpl[K, H, T]} def succImpl[K, H, T](implicit qctx: QuoteContext, k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def name(tp: TypeOrBounds): String = tp match { case Type.ConstantType(Constant(str: String)) => str diff --git a/tests/run-macros/tasty-interpolation-1/Macro.scala b/tests/run-macros/tasty-interpolation-1/Macro.scala index cd236c15c751..b3e1fb06af2a 100644 --- a/tests/run-macros/tasty-interpolation-1/Macro.scala +++ b/tests/run-macros/tasty-interpolation-1/Macro.scala @@ -55,7 +55,7 @@ abstract class MacroStringInterpolator[T] { protected def interpolate(strCtx: StringContext, argExprs: List[Expr[Any]])(given QuoteContext): Expr[T] protected def getStaticStringContext(strCtxExpr: Expr[StringContext])(given qctx: QuoteContext): StringContext = { - import qctx.tasty._ + import qctx.tasty.{_, given} strCtxExpr.unseal.underlyingArgument match { case Select(Typed(Apply(_, List(Apply(_, List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))), _), _) => val strCtxArgs = strCtxArgTrees.map { @@ -69,7 +69,7 @@ abstract class MacroStringInterpolator[T] { } protected def getArgsList(argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): List[Expr[Any]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} argsExpr.unseal.underlyingArgument match { case Typed(Repeated(args, _), _) => args.map(_.seal) case tree => throw new NotStaticlyKnownError("Expected statically known argument list", tree.seal) diff --git a/tests/run-macros/tasty-linenumber-2/quoted_1.scala b/tests/run-macros/tasty-linenumber-2/quoted_1.scala index e79c4d33dec6..e55ba8f1f07f 100644 --- a/tests/run-macros/tasty-linenumber-2/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber-2/quoted_1.scala @@ -10,7 +10,7 @@ object LineNumber { implicit inline def line: LineNumber = ${lineImpl} def lineImpl(given qctx: QuoteContext): Expr[LineNumber] = { - import qctx.tasty._ + import qctx.tasty.{_, given} '{new LineNumber(${rootPosition.startLine})} } diff --git a/tests/run-macros/tasty-linenumber/quoted_1.scala b/tests/run-macros/tasty-linenumber/quoted_1.scala index adfb441a60ca..1645772f11f4 100644 --- a/tests/run-macros/tasty-linenumber/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber/quoted_1.scala @@ -11,7 +11,7 @@ object LineNumber { ${lineImpl('[T])} def lineImpl(x: Type[Unit])(given qctx: QuoteContext): Expr[LineNumber] = { - import qctx.tasty._ + import qctx.tasty.{_, given} '{new LineNumber(${rootPosition.startLine})} } diff --git a/tests/run-macros/tasty-location/quoted_1.scala b/tests/run-macros/tasty-location/quoted_1.scala index 24f2c9ce0dcc..008c1d001a7f 100644 --- a/tests/run-macros/tasty-location/quoted_1.scala +++ b/tests/run-macros/tasty-location/quoted_1.scala @@ -8,7 +8,7 @@ object Location { implicit inline def location: Location = ${impl} def impl(given qctx: QuoteContext): Expr[Location] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def listOwnerNames(sym: Symbol, acc: List[String]): List[String] = if (sym == defn.RootClass || sym == defn.EmptyPackageClass) acc diff --git a/tests/run-macros/tasty-macro-assert/quoted_1.scala b/tests/run-macros/tasty-macro-assert/quoted_1.scala index eae4c7f062ea..7e2252f8ed4d 100644 --- a/tests/run-macros/tasty-macro-assert/quoted_1.scala +++ b/tests/run-macros/tasty-macro-assert/quoted_1.scala @@ -13,7 +13,7 @@ object Asserts { ${impl('cond)} def impl(cond: Expr[Boolean])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val tree = cond.unseal diff --git a/tests/run-macros/tasty-macro-const/quoted_1.scala b/tests/run-macros/tasty-macro-const/quoted_1.scala index c7ed82d60f48..072ffcee2c5d 100644 --- a/tests/run-macros/tasty-macro-const/quoted_1.scala +++ b/tests/run-macros/tasty-macro-const/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def natConst(x: Int): Int = ${ natConstImpl('x) } def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val xTree: Term = x.unseal xTree match { case Inlined(_, _, Literal(Constant(n: Int))) => diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index 4058ae2e045d..9b101ff66bb5 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { inline def fun3[T]: Unit = ${ impl2('[T]) } def impl(x: Expr[Any])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val pos = x.unseal.underlyingArgument.pos val code = x.unseal.underlyingArgument.show '{ @@ -19,7 +19,7 @@ object Macros { } def impl2[T](x: quoted.Type[T])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val pos = x.unseal.pos val code = x.unseal.show '{ @@ -30,7 +30,7 @@ object Macros { def posStr(qctx: QuoteContext)(pos: qctx.tasty.Position): Expr[String] = { given QuoteContext = qctx - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(s"${pos.sourceFile.jpath.getFileName.toString}:[${pos.start}..${pos.end}]") } } diff --git a/tests/run-macros/tasty-original-source/Macros_1.scala b/tests/run-macros/tasty-original-source/Macros_1.scala index 3142d0d1fa19..b322611c0457 100644 --- a/tests/run-macros/tasty-original-source/Macros_1.scala +++ b/tests/run-macros/tasty-original-source/Macros_1.scala @@ -6,7 +6,7 @@ object Macros { implicit inline def withSource(arg: Any): (String, Any) = ${ impl('arg) } private def impl(arg: Expr[Any])(given qctx: QuoteContext): Expr[(String, Any)] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val source = arg.unseal.underlyingArgument.pos.sourceCode.toString '{Tuple2($source, $arg)} } diff --git a/tests/run-macros/tasty-positioned/quoted_1.scala b/tests/run-macros/tasty-positioned/quoted_1.scala index d2bf58c8e235..1d8442c0152b 100644 --- a/tests/run-macros/tasty-positioned/quoted_1.scala +++ b/tests/run-macros/tasty-positioned/quoted_1.scala @@ -11,7 +11,7 @@ object Positioned { implicit inline def apply[T](x: => T): Positioned[T] = ${impl('x)} def impl[T](x: Expr[T])(implicit ev: Type[T], qctx: QuoteContext): Expr[Positioned[T]] = { - import qctx.tasty.{Position => _, _} + import qctx.tasty.{Position => _, _, given} val pos = rootPosition val path = pos.sourceFile.jpath.toString diff --git a/tests/run-macros/tasty-seal-method/quoted_1.scala b/tests/run-macros/tasty-seal-method/quoted_1.scala index 69d777485e0e..78cd9630aa3d 100644 --- a/tests/run-macros/tasty-seal-method/quoted_1.scala +++ b/tests/run-macros/tasty-seal-method/quoted_1.scala @@ -7,7 +7,7 @@ object Asserts { /** Replaces last argument list by 0s */ def zeroLastArgsImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} // For simplicity assumes that all parameters are Int and parameter lists have no more than 3 elements x.unseal.underlyingArgument match { case Apply(fn, args) => @@ -29,7 +29,7 @@ object Asserts { /** Replaces all argument list by 0s */ def zeroAllArgsImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { - import qctx.tasty._ + import qctx.tasty.{_, given} // For simplicity assumes that all parameters are Int and parameter lists have no more than 3 elements def rec(term: Term): Term = term match { case Apply(fn, args) => diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index b183b3226b0b..c610dafc3944 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def simplified[T <: Tuple]: Seq[String] = ${ impl[T] } def impl[T: Type](given qctx: QuoteContext): Expr[Seq[String]] = { - import qctx.tasty._ + import qctx.tasty.{_, given} def unpackTuple(tp: Type): List[Type] = { @tailrec diff --git a/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala b/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala index 68fb46fade94..f5f44a5b6919 100644 --- a/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala +++ b/tests/run-macros/tasty-string-interpolation-reporter-test/Macros_1.scala @@ -24,7 +24,7 @@ object Macro { case ('{ StringContext(${ExprSeq(parts)}: _*) }, ExprSeq(args)) => val reporter = new Reporter { def errorOnPart(msg: String, partIdx: Int): Unit = { - import qctx.tasty._ + import qctx.tasty.{_, given} error(msg, parts(partIdx).unseal.pos) } } @@ -38,7 +38,7 @@ object Macro { val errors = List.newBuilder[Expr[(Int, Int, Int, String)]] val reporter = new Reporter { def errorOnPart(msg: String, partIdx: Int): Unit = { - import qctx.tasty._ + import qctx.tasty.{_, given} val pos = parts(partIdx).unseal.pos errors += '{ Tuple4($partIdx, ${pos.start}, ${pos.end}, $msg) } } diff --git a/tests/run-macros/tasty-subtyping/quoted_1.scala b/tests/run-macros/tasty-subtyping/quoted_1.scala index 913d438db377..5f3cdea1d42b 100644 --- a/tests/run-macros/tasty-subtyping/quoted_1.scala +++ b/tests/run-macros/tasty-subtyping/quoted_1.scala @@ -10,13 +10,13 @@ object Macros { ${isSubTypeOfImpl('[T], '[U])} def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val isTypeEqual = t.unseal.tpe =:= u.unseal.tpe isTypeEqual } def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(given qctx: QuoteContext): Expr[Boolean] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val isTypeEqual = t.unseal.tpe <:< u.unseal.tpe isTypeEqual } diff --git a/tests/run-macros/tasty-tree-map/quoted_1.scala b/tests/run-macros/tasty-tree-map/quoted_1.scala index ed53a95724c7..ba9126412170 100644 --- a/tests/run-macros/tasty-tree-map/quoted_1.scala +++ b/tests/run-macros/tasty-tree-map/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { implicit inline def identityMaped[T](x: => T): T = ${ impl('x) } def impl[T: Type](x: Expr[T])(given qctx: QuoteContext): Expr[T] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val identityMap = new TreeMap { } val transformed = identityMap.transformTerm(x.unseal).seal.cast[T] transformed diff --git a/tests/run-macros/tasty-typeof/Macro_1.scala b/tests/run-macros/tasty-typeof/Macro_1.scala index 95efe4a76c5b..4f1e0ca69c25 100644 --- a/tests/run-macros/tasty-typeof/Macro_1.scala +++ b/tests/run-macros/tasty-typeof/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { inline def testTypeOf(): Unit = ${ testTypeOfImpl } private def testTypeOfImpl(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} '{ assert(${(typeOf[Unit] =:= defn.UnitType)}, "Unit") assert(${(typeOf[Byte] =:= defn.ByteType)}, "Byte") diff --git a/tests/run-macros/tasty-unsafe-let/quoted_1.scala b/tests/run-macros/tasty-unsafe-let/quoted_1.scala index 7f9eff7bc59a..397a47d8d0d1 100644 --- a/tests/run-macros/tasty-unsafe-let/quoted_1.scala +++ b/tests/run-macros/tasty-unsafe-let/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { ${ impl('rhs, 'body) } private def impl[T](rhs: Expr[T], body: Expr[T => Unit])(given qctx: QuoteContext): Expr[Unit] = { - import qctx.tasty._ + import qctx.tasty.{_, given} val rhsTerm = rhs.unseal diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index d60575543866..3d4e77649f6b 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object TypeToolbox { inline def show[A]: String = ${ showImpl('[A]) } private def showImpl[A, B](a: Type[A])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(a.show) } } diff --git a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala index 3c8dd288e373..88f9f0301968 100644 --- a/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-1/XmlQuote_1.scala @@ -14,7 +14,7 @@ object XmlQuote { def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]]) (given qctx: QuoteContext): Expr[Xml] = { - import qctx.tasty._ + import qctx.tasty.{_, given} // for debugging purpose def pp(tree: Tree): Unit = { diff --git a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala index 9986fd16d872..4ec2c1b4257d 100644 --- a/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala +++ b/tests/run-macros/xml-interpolation-2/XmlQuote_1.scala @@ -15,7 +15,7 @@ object XmlQuote { implicit inline def SCOps(ctx: => StringContext): SCOps = new SCOps(ctx) def impl(receiver: Expr[SCOps], args: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[Xml] = { - import qctx.tasty._ + import qctx.tasty.{_, given} // for debugging purpose def pp(tree: Tree): Unit = { diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index 56ac0c87bf17..42c6fbba2ccc 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -4,7 +4,7 @@ import scala.tasty.interpreter.jvm.JVMReflection import scala.tasty.Reflection abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { - import reflect._ + import reflect.{_, given} final val LOG = false diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala index 46ce85f85be4..4387b6099684 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala @@ -5,7 +5,7 @@ import scala.tasty.interpreter.jvm.JVMReflection import scala.tasty.Reflection class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpreter[R](reflect0) { - import reflect._ + import reflect.{_, given} // All references are represented by themselfs and values are boxed type AbstractAny = Any diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala index 3c72766f8282..7b505880bbff 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala @@ -3,7 +3,7 @@ package scala.tasty.interpreter.jvm import scala.tasty.Reflection class JVMReflection[R <: Reflection & Singleton](val reflect: R) { - import reflect._ + import reflect.{_, given} import java.lang.reflect.{InvocationTargetException, Method} private val classLoader: ClassLoader = getClass.getClassLoader diff --git a/tests/run-with-compiler/i6270/Macro_1.scala b/tests/run-with-compiler/i6270/Macro_1.scala index ad8e094e6e59..0b8b16ab5124 100644 --- a/tests/run-with-compiler/i6270/Macro_1.scala +++ b/tests/run-with-compiler/i6270/Macro_1.scala @@ -6,7 +6,7 @@ object api { ${ reflImpl('x) } private def reflImpl(x: Expr[String])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(x.show) } @@ -14,7 +14,7 @@ object api { ${ reflImplColor('x) } private def reflImplColor(x: Expr[String])(given qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(x.show(ANSI)) } } diff --git a/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala b/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala index 33bd0e98af57..ec6d11ac2698 100644 --- a/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala +++ b/tests/run-with-compiler/reflect-sourceCode/Macro_1.scala @@ -5,7 +5,7 @@ object api { ${ reflImpl('x) } private def reflImpl[T](x: Expr[T])(implicit qctx: QuoteContext): Expr[String] = { - import qctx.tasty._ + import qctx.tasty.{_, given} Expr(x.unseal.pos.sourceCode) } } diff --git a/tests/run-with-compiler/tasty-comment-consumer/Test.scala b/tests/run-with-compiler/tasty-comment-consumer/Test.scala index ef2251fa43e9..0bd98f3e789f 100644 --- a/tests/run-with-compiler/tasty-comment-consumer/Test.scala +++ b/tests/run-with-compiler/tasty-comment-consumer/Test.scala @@ -10,7 +10,7 @@ object Test { class CommentConsumer extends TastyConsumer { final def apply(reflect: Reflection)(root: reflect.Tree): Unit = { - import reflect._ + import reflect.{_, given} object Traverser extends TreeTraverser { override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match {