diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 44fdcb7624de..08f8a5c0f8f3 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 44fdcb7624de24512522b3bbf783bdfbec34c680 +Subproject commit 08f8a5c0f8f3a3e8d25e0320e171b386e0c44bb1 diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index 35f92b0deeb1..b2bfc9e3c107 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit 35f92b0deeb1063630c281e9a95118314de26f29 +Subproject commit b2bfc9e3c1078590e130bcfcd09f4ac2d49452e3 diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 76b69159f96a..278c8096070b 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 76b69159f96a4169e6ab3e5792849c5b62ba4fef +Subproject commit 278c8096070b2a10ddd85c4750c737e8babc71ea diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 4e2f1a671532..30f49dddc327 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -292,7 +292,7 @@ object desugar { } } - /** Transforms a definition with a name starting with a `$` in a quoted pattern into a `scala.quoted.binding.Binding` splice. + /** Transforms a definition with a name starting with a `$` in a quoted pattern into a `quoted.binding.Binding` splice. * * The desugaring consists in adding the `@patternBindHole` annotation. This annotation is used during typing to perform the full transformation. * diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 3d463ce2353d..a95d6bdb437a 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -1207,7 +1207,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { /** An extractor for typed splices */ object Splice { def apply(tree: Tree)(implicit ctx: Context): Tree = { - val baseType = tree.tpe.baseType(defn.QuotedExprClass).orElse(tree.tpe.baseType(defn.QuotedTypeTagClass)) + val baseType = tree.tpe.baseType(defn.QuotedExprClass).orElse(tree.tpe.baseType(defn.QuotedTypeClass)) val argType = if (baseType != NoType) baseType.argTypesHi.head else defn.NothingType diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index b6ad3e25724b..c95201086200 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -659,13 +659,13 @@ class Definitions { @tu lazy val InternalQuotedExprModule: Symbol = ctx.requiredModule("scala.internal.quoted.Expr") @tu lazy val InternalQuotedExpr_unapply: Symbol = InternalQuotedExprModule.requiredMethod(nme.unapply) - @tu lazy val InternalQuotedTypeTagModule: Symbol = ctx.requiredModule("scala.internal.quoted.TypeTag") - @tu lazy val InternalQuotedTypeTag_unapply: Symbol = InternalQuotedTypeTagModule.requiredMethod(nme.unapply) + @tu lazy val InternalQuotedTypeModule: Symbol = ctx.requiredModule("scala.internal.quoted.Type") + @tu lazy val InternalQuotedType_unapply: Symbol = InternalQuotedTypeModule.requiredMethod(nme.unapply) - @tu lazy val QuotedTypeTagClass: ClassSymbol = ctx.requiredClass("scala.quoted.TypeTag") - @tu lazy val QuotedTypeTag_splice: Symbol = QuotedTypeTagClass.requiredType(tpnme.splice) + @tu lazy val QuotedTypeClass: ClassSymbol = ctx.requiredClass("scala.quoted.Type") + @tu lazy val QuotedType_splice: Symbol = QuotedTypeClass.requiredType(tpnme.splice) - @tu lazy val QuotedTypeTagModule: Symbol = QuotedTypeTagClass.companionModule + @tu lazy val QuotedTypeModule: Symbol = QuotedTypeClass.companionModule @tu lazy val QuotedMatchingSymClass: ClassSymbol = ctx.requiredClass("scala.quoted.matching.Sym") @tu lazy val TastyReflectionClass: ClassSymbol = ctx.requiredClass("scala.tasty.Reflection") diff --git a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala index 970d1151187c..bd306960eb76 100644 --- a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala @@ -35,14 +35,14 @@ object PickledQuotes { } /** Transform the expression into its fully spliced Tree */ - def quotedExprToTree[T](expr: scala.quoted.Expr[T])(implicit ctx: Context): Tree = { + def quotedExprToTree[T](expr: quoted.Expr[T])(implicit ctx: Context): Tree = { val expr1 = expr.asInstanceOf[TastyTreeExpr[Tree]] QuoteContext.checkScopeId(expr1.scopeId) healOwner(expr1.tree) } /** Transform the expression into its fully spliced TypeTree */ - def quotedTypeToTree(tpe: scala.quoted.TypeTag[?])(implicit ctx: Context): Tree = { + def quotedTypeToTree(tpe: quoted.Type[?])(implicit ctx: Context): Tree = { val tpe1 = tpe.asInstanceOf[TreeType[Tree]] QuoteContext.checkScopeId(tpe1.scopeId) healOwner(tpe1.typeTree) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index faa74db7b4ee..410952c6d078 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1275,7 +1275,7 @@ class TreeUnpickler(reader: TastyReader, else new TreeType(arg, QuoteContext.scopeId) val reifiedArgs = args.map(wrap) val filled = if (isType) { - val quotedType = splice.asInstanceOf[Seq[Any] => scala.quoted.TypeTag[?]](reifiedArgs) + val quotedType = splice.asInstanceOf[Seq[Any] => quoted.Type[?]](reifiedArgs) PickledQuotes.quotedTypeToTree(quotedType) } else { diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 903c54433f67..4610ab003499 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -374,7 +374,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { else if (name.isTypeName) typeText(txt) else txt case tree @ Select(qual, name) => - if (!printDebug && tree.hasType && tree.symbol == defn.QuotedTypeTag_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}") + if (!printDebug && tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}") else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name)) else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided (name != nme.CONSTRUCTOR || printDebug)) case tree: This => @@ -499,7 +499,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (lo eq hi) optText(lo)(" = " ~ _) else optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _) case Bind(name, body) => - keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.TypeTag in quote patterns (not pickled) + keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.Type in quote patterns (not pickled) changePrec(InfixPrec) { toText(name) ~ " @ " ~ toText(body) } case Alternative(trees) => changePrec(OrPrec) { toText(trees, " | ") } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala index 3417ebb1a087..3c3d410b50d0 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala @@ -18,8 +18,6 @@ import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans} import scala.runtime.quoted.Unpickler import scala.tasty.reflect.CompilerInterface -import scala.quoted.{Expr, TypeTag} - class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extends CompilerInterface { import tpd._ @@ -34,10 +32,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend // QUOTE UNPICKLING // - def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): Expr[?] = + def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[?] = new scala.internal.quoted.TastyTreeExpr(PickledQuotes.unpickleExpr(repr, args), compilerId) - def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): TypeTag[?] = + def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[?] = new scala.internal.quoted.TreeType(PickledQuotes.unpickleType(repr, args), compilerId) // @@ -1582,16 +1580,16 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend // QUOTED SEAL/UNSEAL // - /** View this expression `scala.quoted.Expr[?]` as a `Term` */ - def QuotedExpr_unseal(self: Expr[?])(given Context): Term = + /** View this expression `quoted.Expr[?]` as a `Term` */ + def QuotedExpr_unseal(self: scala.quoted.Expr[?])(given Context): Term = PickledQuotes.quotedExprToTree(self) - /** View this expression `scala.quoted.TypeTag[?]` as a `TypeTree` */ - def QuotedType_unseal(self: TypeTag[?])(given Context): TypeTree = + /** View this expression `quoted.Type[?]` as a `TypeTree` */ + def QuotedType_unseal(self: scala.quoted.Type[?])(given Context): TypeTree = PickledQuotes.quotedTypeToTree(self) - /** Convert `Term` to an `scala.quoted.Expr[Any]` */ - def QuotedExpr_seal(self: Term)(given ctx: Context): Expr[Any] = { + /** Convert `Term` to an `quoted.Expr[Any]` */ + def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] = { def etaExpand(term: Term): Term = term.tpe.widen match { case mtpe: Types.MethodType if !mtpe.isParamDependent => val closureResType = mtpe.resType match { @@ -1606,12 +1604,12 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend new scala.internal.quoted.TastyTreeExpr(etaExpand(self), compilerId) } - /** Checked cast to a `scala.quoted.Expr[U]` */ - def QuotedExpr_cast[U](self: Expr[?])(given tp: TypeTag[U], ctx: Context): Expr[U] = { + /** Checked cast to a `quoted.Expr[U]` */ + def QuotedExpr_cast[U](self: scala.quoted.Expr[?])(given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] = { val tree = QuotedExpr_unseal(self) - val expectedType = QuotedType_unseal(tp.asInstanceOf[TypeTag[U]]).tpe + val expectedType = QuotedType_unseal(tp).tpe if (tree.tpe <:< expectedType) - self.asInstanceOf[Expr[U]] + self.asInstanceOf[scala.quoted.Expr[U]] else throw new scala.tasty.reflect.ExprCastError( s"""Expr: ${tree.show} @@ -1620,8 +1618,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend ) } - /** Convert `Type` to an `scala.quoted.TypeTag[?]` */ - def QuotedType_seal(self: Type)(given ctx: Context): TypeTag[?] = { + /** Convert `Type` to an `quoted.Type[?]` */ + def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[?] = { val dummySpan = ctx.owner.span // FIXME new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan), compilerId) } diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 544fbc4ff285..f21abf65b858 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -82,7 +82,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( * that are phase-incorrect can still be healed as follows: * * If `T` is a reference to a type at the wrong level, try to heal it by replacing it with - * `${implicitly[scala.quoted.TypeTag[T]]}`. + * `${implicitly[quoted.Type[T]]}`. */ protected def checkLevel(tree: Tree)(implicit ctx: Context): Tree = { def checkTp(tp: Type): Type = checkType(tree.sourcePos).apply(tp) @@ -123,8 +123,8 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( if (tp.isTerm) ctx.error(i"splice outside quotes", pos) tp - case tp: TypeRef if tp.symbol == defn.QuotedTypeTagClass.typeParams.head => - // Adapt direct references to the type of the type parameter T of a scala.quoted.TypeTag[T]. + case tp: TypeRef if tp.symbol == defn.QuotedTypeClass.typeParams.head => + // Adapt direct references to the type of the type parameter T of a quoted.Type[T]. // Replace it with a properly encoded type splice. This is the normal for expected for type splices. tp.prefix.select(tpnme.splice) case tp: NamedType => @@ -147,7 +147,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( * by which we refer to `sym`. If it is an inconsistent type try construct a healed type for it. * * @return `None` if the phase is correct or cannot be healed - * `Some(tree)` with the `tree` of the healed type tree for `${implicitly[scala.quoted.TypeTag[T]]}` + * `Some(tree)` with the `tree` of the healed type tree for `${implicitly[quoted.Type[T]]}` */ private def checkSymLevel(sym: Symbol, tp: Type, pos: SourcePosition)(implicit ctx: Context): Option[Tree] = { /** Is a reference to a class but not `this.type` */ @@ -196,7 +196,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( None } else { - val reqType = defn.QuotedTypeTagClass.typeRef.appliedTo(tp) + val reqType = defn.QuotedTypeClass.typeRef.appliedTo(tp) val tag = ctx.typer.inferImplicitArg(reqType, pos.span) tag.tpe match { case _: TermRef => diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index ff620108fc5e..ceeff4f42ddb 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -229,15 +229,15 @@ class ReifyQuotes extends MacroTransform { if (isType) ref(defn.Unpickler_unpickleType).appliedToType(originalTp) else ref(defn.Unpickler_unpickleExpr).appliedToType(originalTp.widen) val spliceResType = - if (isType) defn.QuotedTypeTagClass.typeRef.appliedTo(WildcardType) - else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)) | defn.QuotedTypeTagClass.typeRef.appliedTo(WildcardType) + if (isType) defn.QuotedTypeClass.typeRef.appliedTo(WildcardType) + else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)) | defn.QuotedTypeClass.typeRef.appliedTo(WildcardType) val pickledQuoteStrings = liftList(PickledQuotes.pickleQuote(body).map(x => Literal(Constant(x))), defn.StringType) val splicesList = liftList(splices, defn.FunctionType(1).appliedTo(defn.SeqType.appliedTo(defn.AnyType), spliceResType)) meth.appliedTo(pickledQuoteStrings, splicesList) } if (isType) { - def tag(tagName: String) = ref(defn.QuotedTypeTagModule).select(tagName.toTermName).appliedTo(qctx) + def tag(tagName: String) = ref(defn.QuotedTypeModule).select(tagName.toTermName).appliedTo(qctx) if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag") else pickleAsTasty().select(nme.apply).appliedTo(qctx) } @@ -311,7 +311,7 @@ class ReifyQuotes extends MacroTransform { } assert(tpw.isInstanceOf[ValueType]) val argTpe = - if (tree.isType) defn.QuotedTypeTagClass.typeRef.appliedTo(tpw) + if (tree.isType) defn.QuotedTypeClass.typeRef.appliedTo(tpw) else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(tpw)) val selectArg = arg.select(nme.apply).appliedTo(Literal(Constant(i))).cast(argTpe) val capturedArg = SyntheticValDef(UniqueName.fresh(tree.symbol.name.toTermName).toTermName, selectArg) diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index 18755bb718ee..929a2a056fce 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -63,9 +63,9 @@ class Staging extends MacroTransform { } tree.tpe match { - case tpe @ TypeRef(prefix, _) if tpe.typeSymbol eq defn.QuotedTypeTag_splice => + case tpe @ TypeRef(prefix, _) if tpe.typeSymbol eq defn.QuotedType_splice => // Type splices must have a know term ref, usually to an implicit argument - // This is mostly intended to catch `scala.quoted.TypeTag[T]#splice` types which should just be `T` + // This is mostly intended to catch `quoted.Type[T]#splice` types which should just be `T` assert(prefix.isInstanceOf[TermRef] || prefix.isInstanceOf[ThisType], prefix) case _ => // OK diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index 7be5ceda07ab..3f5222c16cd3 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -213,5 +213,5 @@ class SymUtils(val self: Symbol) extends AnyVal { /** Is symbol a splice operation? */ def isSplice(implicit ctx: Context): Boolean = - self == defn.InternalQuoted_exprSplice || self == defn.QuotedTypeTag_splice + self == defn.InternalQuoted_exprSplice || self == defn.QuotedType_splice } diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 562f885b4156..f740aa6fd072 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -705,7 +705,7 @@ trait Implicits { self: Typer => EmptyTree } - /** Synthesize the tree for `'[T]` for an implicit `scala.quoted.TypeTag[T]`. + /** Synthesize the tree for `'[T]` for an implicit `scala.quoted.Type[T]`. * `T` is deeply dealiased to avoid references to local type aliases. */ lazy val synthesizedTypeTag: SpecialHandler = { @@ -1076,7 +1076,7 @@ trait Implicits { self: Typer => if (mySpecialHandlers == null) mySpecialHandlers = List( defn.ClassTagClass -> synthesizedClassTag, - defn.QuotedTypeTagClass -> synthesizedTypeTag, + defn.QuotedTypeClass -> synthesizedTypeTag, defn.QuoteContextClass -> synthesizedQuoteContext, defn.EqlClass -> synthesizedEq, defn.TupledFunctionClass -> synthesizedTupleFunction, diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index 1ed0020aa906..e1916b26da7e 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -32,7 +32,7 @@ trait QuotesAndSplices { import tpd._ - /** Translate `'{ t }` into `scala.quoted.Expr.apply(t)` and `'[T]` into `scala.quoted.TypeTag.apply[T]` + /** Translate `'{ t }` into `scala.quoted.Expr.apply(t)` and `'[T]` into `scala.quoted.Type.apply[T]` * while tracking the quotation level in the context. */ def typedQuote(tree: untpd.Quote, pt: Type)(implicit ctx: Context): Tree = { @@ -113,7 +113,7 @@ trait QuotesAndSplices { } val typeSym = ctx.newSymbol(spliceOwner(ctx), name, EmptyFlags, TypeBounds.empty, NoSymbol, tree.expr.span) typeSym.addAnnotation(Annotation(New(ref(defn.InternalQuoted_patternBindHoleAnnot.typeRef)).withSpan(tree.expr.span))) - val pat = typedPattern(tree.expr, defn.QuotedTypeTagClass.typeRef.appliedTo(typeSym.typeRef))( + val pat = typedPattern(tree.expr, defn.QuotedTypeClass.typeRef.appliedTo(typeSym.typeRef))( spliceContext.retractMode(Mode.QuotedPattern).withOwner(spliceOwner(ctx))) pat.select(tpnme.splice) } @@ -190,7 +190,7 @@ trait QuotesAndSplices { val pat1 = if (patType eq patType1) pat else pat.withType(patType1) patBuf += pat1 } - case Select(pat, _) if tree.symbol == defn.QuotedTypeTag_splice => + case Select(pat, _) if tree.symbol == defn.QuotedType_splice => val sym = tree.tpe.dealias.typeSymbol.asType val tdef = TypeDef(sym).withSpan(sym.span) freshTypeBindingsBuff += transformTypeBindingTypeDef(tdef, freshTypePatBuf) @@ -232,7 +232,7 @@ trait QuotesAndSplices { if (variance == -1) tdef.symbol.addAnnotation(Annotation(New(ref(defn.InternalQuoted_fromAboveAnnot.typeRef)).withSpan(tdef.span))) val bindingType = getBinding(tdef.symbol).symbol.typeRef - val bindingTypeTpe = AppliedType(defn.QuotedTypeTagClass.typeRef, bindingType :: Nil) + val bindingTypeTpe = AppliedType(defn.QuotedTypeClass.typeRef, bindingType :: Nil) assert(tdef.name.startsWith("$")) val bindName = tdef.name.toString.stripPrefix("$").toTermName val sym = ctx0.newPatternBoundSymbol(bindName, bindingTypeTpe, tdef.span, flags = ImplicitTerm) @@ -254,7 +254,7 @@ trait QuotesAndSplices { val isFreshTypeBindings = freshTypeBindings.map(_.symbol).toSet val typeMap = new TypeMap() { def apply(tp: Type): Type = tp match { - case tp: TypeRef if tp.typeSymbol == defn.QuotedTypeTag_splice => + case tp: TypeRef if tp.typeSymbol == defn.QuotedType_splice => val tp1 = tp.dealias if (isFreshTypeBindings(tp1.typeSymbol)) tp1 else tp @@ -331,7 +331,7 @@ trait QuotesAndSplices { class ReplaceBindings extends TypeMap() { override def apply(tp: Type): Type = tp match { case tp: TypeRef => - val tp1 = if (tp.typeSymbol == defn.QuotedTypeTag_splice) tp.dealias else tp + val tp1 = if (tp.typeSymbol == defn.QuotedType_splice) tp.dealias else tp typeBindings.get(tp1.typeSymbol).fold(tp)(_.symbol.typeRef) case tp => mapOver(tp) } @@ -364,8 +364,8 @@ trait QuotesAndSplices { val splicePat = typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType) - val unapplySym = if (tree.quoted.isTerm) defn.InternalQuotedExpr_unapply else defn.InternalQuotedTypeTag_unapply - val quoteClass = if (tree.quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeTagClass + val unapplySym = if (tree.quoted.isTerm) defn.InternalQuotedExpr_unapply else defn.InternalQuotedType_unapply + val quoteClass = if (tree.quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass val quotedPattern = if (tree.quoted.isTerm) ref(defn.InternalQuoted_exprQuote.termRef).appliedToType(defn.AnyType).appliedTo(shape).select(nme.apply).appliedTo(qctx) else ref(defn.InternalQuoted_typeQuote.termRef).appliedToTypeTrees(shape :: Nil) diff --git a/compiler/test-resources/pending/repl/i4539 b/compiler/test-resources/pending/repl/i4539 index a87b656a2b76..ee14431b71bb 100644 --- a/compiler/test-resources/pending/repl/i4539 +++ b/compiler/test-resources/pending/repl/i4539 @@ -1,7 +1,7 @@ scala> val a = '[Int] -val a: quoted.TypeTag[Int] = TypeTag(Int) +val a: quoted.Type[Int] = Type(Int) scala> '[Int] -val res0: quoted.TypeTag[Int] = TypeTag(Int) +val res0: quoted.Type[Int] = Type(Int) scala> '[Int]; '[Int] -val res1: quoted.TypeTag[Int] = TypeTag(Int) -val res2: quoted.TypeTag[Int] = TypeTag(Int) +val res1: quoted.Type[Int] = Type(Int) +val res2: quoted.Type[Int] = Type(Int) diff --git a/docs/docs/reference/metaprogramming/macros.md b/docs/docs/reference/metaprogramming/macros.md index 0566c1cafa66..0ad19aa737fa 100644 --- a/docs/docs/reference/metaprogramming/macros.md +++ b/docs/docs/reference/metaprogramming/macros.md @@ -77,21 +77,21 @@ The type signatures of quotes and splices can be described using two fundamental types: - `Expr[T]`: abstract syntax trees representing expressions of type `T` - - `TypeTag[T]`: type structures representing type `T`. + - `Type[T]`: type structures representing type `T`. Quoting takes expressions of type `T` to expressions of type `Expr[T]` -and it takes types `T` to expressions of type `TypeTag[T]`. Splicing +and it takes types `T` to expressions of type `Type[T]`. Splicing takes expressions of type `Expr[T]` to expressions of type `T` and it -takes expressions of type `TypeTag[T]` to types `T`. +takes expressions of type `Type[T]` to types `T`. The two types can be defined in package `scala.quoted` as follows: ```scala package scala.quoted -sealed trait Expr[+T] -sealed trait TypeTag[T] +sealed abstract class Expr[+T] +sealed abstract class Type[T] ``` -Both `Expr` and `TypeTag` are abstract and sealed, so all constructors for +Both `Expr` and `Type` are abstract and sealed, so all constructors for these types are provided by the system. One way to construct values of these types is by quoting, the other is by type-specific lifting operations that will be discussed later on. @@ -168,31 +168,31 @@ as for expressions. This might seem too restrictive. Indeed, the definition of `reflect` above is not phase correct since there is a quote but no splice between the parameter binding of `T` and its usage. But the code can be made phase correct by adding a binding -of a `TypeTag[T]` tag: +of a `Type[T]` tag: ```scala -def reflect[T, U](f: Expr[T] => Expr[U]) given (t: TypeTag[T]): Expr[T => U] = +def reflect[T, U](f: Expr[T] => Expr[U]) given (t: Type[T]): Expr[T => U] = '{ (x: $t) => ${ f('x) } } ``` In this version of `reflect`, the type of `x` is now the result of -splicing the `TypeTag` value `t`. This operation _is_ splice correct -- there +splicing the `Type` value `t`. This operation _is_ splice correct -- there is one quote and one splice between the use of `t` and its definition. To avoid clutter, the Scala implementation tries to convert any phase-incorrect -reference to a type `T` to a type-splice, by rewriting `T` to `${ summon[TypeTag[T]] }`. +reference to a type `T` to a type-splice, by rewriting `T` to `${ summon[Type[T]] }`. For instance, the user-level definition of `reflect`: ```scala -def reflect[T: TypeTag, U: TypeTag](f: Expr[T] => Expr[U]): Expr[T => U] = +def reflect[T: Type, U: Type](f: Expr[T] => Expr[U]): Expr[T => U] = '{ (x: T) => ${ f('x) } } ``` would be rewritten to ```scala -def reflect[T: TypeTag, U: TypeTag](f: Expr[T] => Expr[U]): Expr[T => U] = - '{ (x: ${ summon[TypeTag[T]] }) => ${ f('x) } } +def reflect[T: Type, U: Type](f: Expr[T] => Expr[U]): Expr[T => U] = + '{ (x: ${ summon[Type[T]] }) => ${ f('x) } } ``` The `the` query succeeds because there is a given instance of -type `TypeTag[T]` available (namely the given parameter corresponding -to the context bound `: TypeTag`), and the reference to that value is +type `Type[T]` available (namely the given parameter corresponding +to the context bound `: Type`), and the reference to that value is phase-correct. If that was not the case, the phase inconsistency for `T` would be reported as an error. @@ -297,7 +297,7 @@ given [T: Liftable] : Liftable[List[T]] { In the end, `Liftable` resembles very much a serialization framework. Like the latter it can be derived systematically for all collections, case classes and enums. Note also that the synthesis -of _type-tag_ values of type `TypeTag[T]` is essentially the type-level +of _type-tag_ values of type `Type[T]` is essentially the type-level analogue of lifting. Using lifting, we can now give the missing definition of `showExpr` in the introductory example: @@ -319,7 +319,7 @@ stages. The previous section has shown that the metaprogramming framework has to be able to take a type `T` and convert it to a type tree of type -`TypeTag[T]` that can be reified. This means that all free variables of +`Type[T]` that can be reified. This means that all free variables of the type tree refer to types and values defined in the current stage. For a reference to a global class, this is easy: Just issue the fully @@ -327,19 +327,19 @@ qualified name of the class. Members of reifiable types are handled by just reifying the containing type together with the member name. But what to do for references to type parameters or local type definitions that are not defined in the current stage? Here, we cannot construct -the `TypeTag[T]` tree directly, so we need to get it from a recursive +the `Type[T]` tree directly, so we need to get it from a recursive implicit search. For instance, to implement ```scala -summon[TypeTag[List[T]]] +summon[Type[List[T]]] ``` where `T` is not defined in the current stage, we construct the type constructor -of `List` applied to the splice of the result of searching for a given instance for `TypeTag[T]`: +of `List` applied to the splice of the result of searching for a given instance for `Type[T]`: ```scala -'[ List[ ${ summon[TypeTag[T]] } ] ] +'[ List[ ${ summon[Type[T]] } ] ] ``` This is exactly the algorithm that Scala 2 uses to search for type tags. In fact Scala 2's type tag feature can be understood as a more ad-hoc version of -`scala.quoted.TypeTag`. As was the case for type tags, the implicit search for a `TypeTag` +`quoted.Type`. As was the case for type tags, the implicit search for a `quoted.Type` is handled by the compiler, using the algorithm sketched above. ### Relationship with Inline @@ -489,7 +489,7 @@ function `f` and one `sum` that performs a sum by delegating to `map`. ```scala object Macros { - def map[T](arr: Expr[Array[T]], f: Expr[T] => Expr[Unit])(implicit t: TypeTag[T]): Expr[Unit] = '{ + def map[T](arr: Expr[Array[T]], f: Expr[T] => Expr[Unit])(implicit t: Type[T]): Expr[Unit] = '{ var i: Int = 0 while (i < ($arr).length) { val element: $t = ($arr)(i) @@ -573,7 +573,7 @@ in a quote context. For this we simply provide `scala.quoted.matching.searchImpl ```scala inline def setFor[T]: Set[T] = ${ setForExpr[T] } -def setForExpr[T: TypeTag](given QuoteContext): Expr[Set[T]] = { +def setForExpr[T: Type](given QuoteContext): Expr[Set[T]] = { searchImplicitExpr[Ordering[T]] match { case Some(ord) => '{ new TreeSet[T]()($ord) } case _ => '{ new HashSet[T] } diff --git a/docs/docs/reference/metaprogramming/tasty-reflect.md b/docs/docs/reference/metaprogramming/tasty-reflect.md index 7947de0561c7..5ab40ba057d9 100644 --- a/docs/docs/reference/metaprogramming/tasty-reflect.md +++ b/docs/docs/reference/metaprogramming/tasty-reflect.md @@ -4,8 +4,8 @@ title: "TASTy Reflect" --- TASTy Reflect enables inspection and construction of Typed Abstract Syntax Trees -(Typed-AST). It may be used on quoted expressions (`scala.quoted.Expr`) and quoted -types (`scala.quoted.TypeTag`) from [Macros](./macros.md) or on full TASTy files. +(Typed-AST). It may be used on quoted expressions (`quoted.Expr`) and quoted +types (`quoted.Type`) from [Macros](./macros.md) or on full TASTy files. If you are writing macros, please first read [Macros](./macros.md). You may find all you need without using TASTy Reflect. @@ -13,7 +13,7 @@ You may find all you need without using TASTy Reflect. ## API: From quotes and splices to TASTy reflect trees and back -With `scala.quoted.Expr` and `scala.quoted.TypeTag` we can compute code but also analyze code +With `quoted.Expr` and `quoted.Type` we can compute code but also analyze code by inspecting the ASTs. [Macros](./macros.md) provides the guarantee that the generation of code will be type-correct. Using TASTy Reflect will break these guarantees and may fail at macro expansion time, hence additional explicit @@ -36,8 +36,8 @@ def natConstImpl(x: Expr[Int])(given qctx: QuoteContext): Expr[Int] = { ### Sealing and Unsealing -`import qctx.tasty.{_, given}` will provide an `unseal` extension method on `scala.quoted.Expr` -and `scala.quoted.TypeTag` which returns a `qctx.tasty.Term` that represents the tree of +`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 trees. For example the `Literal(_)` extractor used below. @@ -65,7 +65,7 @@ To easily know which extractors are needed, the `showExtractors` method on a `qctx.tasty.Term` returns the string representation of the extractors. The method `qctx.tasty.Term.seal[T]` provides a way to go back to a -`scala.quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type +`quoted.Expr[Any]`. Note that the type is `Expr[Any]`. Consequently, the type must be set explicitly with a checked `cast` call. If the type does not conform to it an exception will be thrown. In the code above, we could have replaced `Expr(n)` by `xTree.seal.cast[Int]`. diff --git a/docs/docs/reference/other-new-features/quoted-pattern-spec.md b/docs/docs/reference/other-new-features/quoted-pattern-spec.md index 7fa4c0ad6cdb..07712dad0ce6 100644 --- a/docs/docs/reference/other-new-features/quoted-pattern-spec.md +++ b/docs/docs/reference/other-new-features/quoted-pattern-spec.md @@ -29,7 +29,7 @@ def foo(x: Expr[Int]) given tasty.Reflect: Expr[Int] = x match { ## Runtime semantics -At runtime to a `scala.quoted.Expr` can be matched to another using `scala.internal.quoted.Expr.unapply`. +At runtime to a `quoted.Expr` can be matched to another using `scala.internal.quoted.Expr.unapply`. ```scala def unapply[Tup <: Tuple](scrutineeExpr: Expr[_])(implicit patternExpr: Expr[_], reflection: Reflection): Option[Tup] diff --git a/library/src-bootstrapped/scala/quoted/Expr.scala b/library/src-bootstrapped/scala/quoted/Expr.scala deleted file mode 100644 index 7a045d8c59b8..000000000000 --- a/library/src-bootstrapped/scala/quoted/Expr.scala +++ /dev/null @@ -1,197 +0,0 @@ -package scala - -package quoted { - - import scala.quoted.show.SyntaxHighlight - - sealed trait Expr[+T] { - - /** Show a source code like representation of this expression without syntax highlight */ - def show(implicit qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) - - /** Show a source code like representation of this expression */ - def show(syntaxHighlight: SyntaxHighlight)(implicit qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) - - /** Return the value of this expression. - * - * Returns `None` if the expression does not contain a value or contains side effects. - * Otherwise returns the `Some` of the value. - */ - final def getValue[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) - - } - - object Expr { - - import scala.internal.quoted._ - - /** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */ - type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, [X] =>> (given QuoteContext) => Expr[X]] - - /** `Expr.betaReduce(f)(x1, ..., xn)` is functionally the same as `'{($f)($x1, ..., $xn)}`, however it optimizes this call - * by returning the result of beta-reducing `f(x1, ..., xn)` if `f` is a known lambda expression. - * - * `Expr.betaReduce` distributes applications of `Expr` over function arrows - * ```scala - * Expr.betaReduce(_): Expr[(T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) - * ``` - */ - 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.{_, given} - tg.untupled(args => qctx.tasty.internal.betaReduce(f.unseal, args.toArray.toList.map(_.asInstanceOf[QuoteContext => Expr[_]](qctx).unseal)).seal.asInstanceOf[Expr[R]]) - } - - /** `Expr.betaReduceGiven(f)(x1, ..., xn)` is functionally the same as `'{($f)(given $x1, ..., $xn)}`, however it optimizes this call - * by returning the result of beta-reducing `f(given x1, ..., xn)` if `f` is a known lambda expression. - * - * `Expr.betaReduceGiven` distributes applications of `Expr` over function arrows - * ```scala - * Expr.betaReduceGiven(_): Expr[(given T1, ..., Tn) => R] => ((Expr[T1], ..., Expr[Tn]) => Expr[R]) - * ``` - * 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.{_, 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.{_, 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.{_, given} - Literal(Constant(())).seal.asInstanceOf[Expr[Unit]] - } - - /** Returns an expression containing a block with the given statements and ending with the expresion - * Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression - * will be equivalent to `'{ $s1; $s2; ...; $e }`. - */ - def block[T](statements: List[Expr[_]], expr: Expr[T])(given qctx: QuoteContext): Expr[T] = { - import qctx.tasty.{_, given} - Block(statements.map(_.unseal), expr.unseal).seal.asInstanceOf[Expr[T]] - } - - /** Lift a value into an expression containing the construction of that value */ - def apply[T: Liftable](x: T)(given QuoteContext): Expr[T] = summon[Liftable[T]].toExpr(x) - - /** Lifts this sequence of expressions into an expression of a sequence - * - * Transforms a sequence of expression - * `Seq(e1, e2, ...)` where `ei: Expr[T]` - * to an expression equivalent to - * `'{ Seq($e1, $e2, ...) }` typed as an `Expr[Seq[T]]` - * - * Usage: - * ```scala - * '{ List(${Expr.ofSeq(List(1, 2, 3))}: _*) } // equvalent to '{ List(1, 2, 3) } - * ``` - */ - def ofSeq[T](xs: Seq[Expr[T]])(given tp: TypeTag[T], qctx: QuoteContext): Expr[Seq[T]] = { - import qctx.tasty.{_, given} - Repeated(xs.map(_.unseal).toList, tp.unseal).seal.asInstanceOf[Expr[Seq[T]]] - } - - - /** Lifts this list of expressions into an expression of a list - * - * Transforms a list of expression - * `List(e1, e2, ...)` where `ei: Expr[T]` - * to an expression equivalent to - * `'{ List($e1, $e2, ...) }` typed as an `Expr[List[T]]` - */ - def ofList[T](xs: Seq[Expr[T]])(given TypeTag[T], QuoteContext): Expr[List[T]] = - if (xs.isEmpty) '{ Nil } else '{ List(${ofSeq(xs)}: _*) } - - /** Lifts this sequence of expressions into an expression of a tuple - * - * Transforms a sequence of expression - * `Seq(e1, e2, ...)` where `ei: Expr[_]` - * to an expression equivalent to - * `'{ ($e1, $e2, ...) }` typed as an `Expr[Tuple]` - */ - def ofTuple(seq: Seq[Expr[_]])(given QuoteContext): Expr[Tuple] = { - seq match { - case Seq() => - unitExpr - case Seq('{ $x1: $t1 }) => - '{ Tuple1($x1) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }) => - '{ Tuple2($x1, $x2) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }) => - '{ Tuple3($x1, $x2, $x3) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }) => - '{ Tuple4($x1, $x2, $x3, $x4) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }) => - '{ Tuple5($x1, $x2, $x3, $x4, $x5) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }) => - '{ Tuple6($x1, $x2, $x3, $x4, $x5, $x6) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }) => - '{ Tuple7($x1, $x2, $x3, $x4, $x5, $x6, $x7) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }) => - '{ Tuple8($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }) => - '{ Tuple9($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }) => - '{ Tuple10($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }) => - '{ Tuple11($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }) => - '{ Tuple12($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }) => - '{ Tuple13($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }) => - '{ Tuple14($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }) => - '{ Tuple15($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }) => - '{ Tuple16($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }) => - '{ Tuple17($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }) => - '{ Tuple18($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }, '{ $x19: $t19 }) => - '{ Tuple19($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }, '{ $x19: $t19 }, '{ $x20: $t20 }) => - '{ Tuple20($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }, '{ $x19: $t19 }, '{ $x20: $t20 }, '{ $x21: $t21 }) => - '{ Tuple21($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21) } - case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }, '{ $x19: $t19 }, '{ $x20: $t20 }, '{ $x21: $t21 }, '{ $x22: $t22 }) => - '{ Tuple22($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21, $x22) } - case _ => - '{ Tuple.fromIArray(IArray(${ofSeq(seq)}: _*)) } - } - } - - /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */ - def ofTuple[T <: Tuple : Tuple.IsMappedBy[Expr]](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).asInstanceOf[Expr[Tuple.InverseMap[T, Expr]]] - } - } - -} - -package internal { - package quoted { - - import scala.quoted.Expr - - /** An Expr backed by a tree. Only the current compiler trees are allowed. - * - * These expressions are used for arguments of macros. They contain and actual tree - * from the program that is being expanded by the macro. - * - * May contain references to code defined outside this TastyTreeExpr instance. - */ - final class TastyTreeExpr[Tree](val tree: Tree, val scopeId: Int) extends Expr[Any] { - override def toString: String = s"Expr()" - } - - } -} diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 8b2f2cad5c29..0cb32a593c0b 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -2,7 +2,7 @@ package scala.quoted import scala.reflect.ClassTag -/** A typeclass for types that can be turned to `scala.quoted.Expr[T]` +/** A typeclass for types that can be turned to `quoted.Expr[T]` * without going through an explicit `'{...}` operation. */ trait Liftable[T] { @@ -45,12 +45,12 @@ object Liftable { } } - given ClassTagIsLiftable[T: TypeTag] : Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { + given ClassTagIsLiftable[T: Type] : Liftable[ClassTag[T]] = new Liftable[ClassTag[T]] { def toExpr(ct: ClassTag[T]): (given QuoteContext) => Expr[ClassTag[T]] = '{ ClassTag[T](${Expr(ct.runtimeClass.asInstanceOf[Class[T]])}) } } - given ArrayIsLiftable[T: TypeTag: Liftable: ClassTag] : Liftable[Array[T]] = new Liftable[Array[T]] { + given ArrayIsLiftable[T: Type: Liftable: ClassTag] : Liftable[Array[T]] = new Liftable[Array[T]] { def toExpr(arr: Array[T]): (given QuoteContext) => Expr[Array[T]] = '{ Array[T](${Expr(arr.toSeq)}: _*)(${Expr(summon[ClassTag[T]])}) } } @@ -103,192 +103,192 @@ object Liftable { else '{ Array(${Expr(array(0))}, ${Expr(array.toSeq.tail)}: _*) } } - given iArrayIsLiftable[T: TypeTag](given ltArray: Liftable[Array[T]]): Liftable[IArray[T]] { + given iArrayIsLiftable[T: Type](given ltArray: Liftable[Array[T]]): Liftable[IArray[T]] { def toExpr(iarray: IArray[T]): (given QuoteContext) => Expr[IArray[T]] = '{ ${ltArray.toExpr(iarray.asInstanceOf[Array[T]])}.asInstanceOf[IArray[T]] } } - given [T: TypeTag: Liftable] : Liftable[Seq[T]] = new Liftable[Seq[T]] { + given [T: Type: Liftable] : Liftable[Seq[T]] = new Liftable[Seq[T]] { def toExpr(xs: Seq[T]): (given QuoteContext) => Expr[Seq[T]] = Expr.ofSeq(xs.map(summon[Liftable[T]].toExpr)) } - given [T: TypeTag: Liftable] : Liftable[List[T]] = new Liftable[List[T]] { + given [T: Type: Liftable] : Liftable[List[T]] = new Liftable[List[T]] { def toExpr(xs: List[T]): (given QuoteContext) => Expr[List[T]] = Expr.ofList(xs.map(summon[Liftable[T]].toExpr)) } - given [T: TypeTag: Liftable] : Liftable[Set[T]] = new Liftable[Set[T]] { + given [T: Type: Liftable] : Liftable[Set[T]] = new Liftable[Set[T]] { def toExpr(set: Set[T]): (given QuoteContext) => Expr[Set[T]] = '{ Set(${Expr(set.toSeq)}: _*) } } - given [T: TypeTag: Liftable, U: TypeTag: Liftable] : Liftable[Map[T, U]] = new Liftable[Map[T, U]] { + given [T: Type: Liftable, U: Type: Liftable] : Liftable[Map[T, U]] = new Liftable[Map[T, U]] { def toExpr(map: Map[T, U]): (given QuoteContext) => Expr[Map[T, U]] = '{ Map(${Expr(map.toSeq)}: _*) } } - given [T: TypeTag: Liftable] : Liftable[Option[T]] = new Liftable[Option[T]] { + given [T: Type: Liftable] : Liftable[Option[T]] = new Liftable[Option[T]] { def toExpr(x: Option[T]): (given QuoteContext) => Expr[Option[T]] = x match { case Some(x) => '{ Some[T](${Expr(x)}) } case None => '{ None: Option[T] } } } - given [L: TypeTag: Liftable, R: TypeTag: Liftable] : Liftable[Either[L, R]] = new Liftable[Either[L, R]] { + given [L: Type: Liftable, R: Type: Liftable] : Liftable[Either[L, R]] = new Liftable[Either[L, R]] { def toExpr(x: Either[L, R]): (given QuoteContext) => Expr[Either[L, R]] = x match { case Left(x) => '{ Left[L, R](${Expr(x)}) } case Right(x) => '{ Right[L, R](${Expr(x)}) } } } - given [T1: TypeTag: Liftable] : Liftable[Tuple1[T1]] = new { + given [T1: Type: Liftable] : Liftable[Tuple1[T1]] = new { def toExpr(tup: Tuple1[T1]) = '{ Tuple1(${Expr(tup._1)}) } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable] : Liftable[Tuple2[T1, T2]] = new { + given [T1: Type: Liftable, T2: Type: Liftable] : Liftable[Tuple2[T1, T2]] = new { def toExpr(tup: Tuple2[T1, T2]) = '{ (${Expr(tup._1)}, ${Expr(tup._2)}) } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable] : Liftable[Tuple3[T1, T2, T3]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable] : Liftable[Tuple3[T1, T2, T3]] = new { def toExpr(tup: Tuple3[T1, T2, T3]) = '{ (${Expr(tup._1)}, ${Expr(tup._2)}, ${Expr(tup._3)}) } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable] : Liftable[Tuple4[T1, T2, T3, T4]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable] : Liftable[Tuple4[T1, T2, T3, T4]] = new { def toExpr(tup: Tuple4[T1, T2, T3, T4]) = '{ (${Expr(tup._1)}, ${Expr(tup._2)}, ${Expr(tup._3)}, ${Expr(tup._4)}) } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable] : Liftable[Tuple5[T1, T2, T3, T4, T5]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable] : Liftable[Tuple5[T1, T2, T3, T4, T5]] = new { def toExpr(tup: Tuple5[T1, T2, T3, T4, T5]) = { val (x1, x2, x3, x4, x5) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable] : Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable] : Liftable[Tuple6[T1, T2, T3, T4, T5, T6]] = new { def toExpr(tup: Tuple6[T1, T2, T3, T4, T5, T6]) = { val (x1, x2, x3, x4, x5, x6) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable] : Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable] : Liftable[Tuple7[T1, T2, T3, T4, T5, T6, T7]] = new { def toExpr(tup: Tuple7[T1, T2, T3, T4, T5, T6, T7]) = { val (x1, x2, x3, x4, x5, x6, x7) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable] : Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable] : Liftable[Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]] = new { def toExpr(tup: Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]) = { val (x1, x2, x3, x4, x5, x6, x7, x8) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable] : Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable] : Liftable[Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]] = new { def toExpr(tup: Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable] : Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable] : Liftable[Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]] = new { def toExpr(tup: Tuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable] : Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable] : Liftable[Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]] = new { def toExpr(tup: Tuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable] : Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable] : Liftable[Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]] = new { def toExpr(tup: Tuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable] : Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable] : Liftable[Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]] = new { def toExpr(tup: Tuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable] : Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable] : Liftable[Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]] = new { def toExpr(tup: Tuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable] : Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable] : Liftable[Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]] = new { def toExpr(tup: Tuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable] : Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable] : Liftable[Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]] = new { def toExpr(tup: Tuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable] : Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable] : Liftable[Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]] = new { def toExpr(tup: Tuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable, T18: TypeTag: Liftable] : Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable] : Liftable[Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]] = new { def toExpr(tup: Tuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable, T18: TypeTag: Liftable, T19: TypeTag: Liftable] : Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable] : Liftable[Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]] = new { def toExpr(tup: Tuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable, T18: TypeTag: Liftable, T19: TypeTag: Liftable, T20: TypeTag: Liftable] : Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable] : Liftable[Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]] = new { def toExpr(tup: Tuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable, T18: TypeTag: Liftable, T19: TypeTag: Liftable, T20: TypeTag: Liftable, T21: TypeTag: Liftable] : Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable] : Liftable[Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]] = new { def toExpr(tup: Tuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}, ${Expr(x21)}) } } } - given [T1: TypeTag: Liftable, T2: TypeTag: Liftable, T3: TypeTag: Liftable, T4: TypeTag: Liftable, T5: TypeTag: Liftable, T6: TypeTag: Liftable, T7: TypeTag: Liftable, T8: TypeTag: Liftable, T9: TypeTag: Liftable, T10: TypeTag: Liftable, T11: TypeTag: Liftable, T12: TypeTag: Liftable, T13: TypeTag: Liftable, T14: TypeTag: Liftable, T15: TypeTag: Liftable, T16: TypeTag: Liftable, T17: TypeTag: Liftable, T18: TypeTag: Liftable, T19: TypeTag: Liftable, T20: TypeTag: Liftable, T21: TypeTag: Liftable, T22: TypeTag: Liftable] : Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { + given [T1: Type: Liftable, T2: Type: Liftable, T3: Type: Liftable, T4: Type: Liftable, T5: Type: Liftable, T6: Type: Liftable, T7: Type: Liftable, T8: Type: Liftable, T9: Type: Liftable, T10: Type: Liftable, T11: Type: Liftable, T12: Type: Liftable, T13: Type: Liftable, T14: Type: Liftable, T15: Type: Liftable, T16: Type: Liftable, T17: Type: Liftable, T18: Type: Liftable, T19: Type: Liftable, T20: Type: Liftable, T21: Type: Liftable, T22: Type: Liftable] : Liftable[Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]] = new { def toExpr(tup: Tuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]) = { val (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) = tup '{ (${Expr(x1)}, ${Expr(x2)}, ${Expr(x3)}, ${Expr(x4)}, ${Expr(x5)}, ${Expr(x6)}, ${Expr(x7)}, ${Expr(x8)}, ${Expr(x9)}, ${Expr(x10)}, ${Expr(x11)}, ${Expr(x12)}, ${Expr(x13)}, ${Expr(x14)}, ${Expr(x15)}, ${Expr(x16)}, ${Expr(x17)}, ${Expr(x18)}, ${Expr(x19)}, ${Expr(x20)}, ${Expr(x21)}, ${Expr(x22)}) } } } - given [H: TypeTag: Liftable, T <: Tuple: TypeTag: Liftable] : Liftable[H *: T] = new { + given [H: Type: Liftable, T <: Tuple: Type: Liftable] : Liftable[H *: T] = new { def toExpr(tup: H *: T): (given QuoteContext) => Expr[H *: T] = '{ ${summon[Liftable[H]].toExpr(tup.head)} *: ${summon[Liftable[T]].toExpr(tup.tail)} } // '{ ${Expr(tup.head)} *: ${Expr(tup.tail)} } // TODO figure out why this fails during CI documentation diff --git a/library/src-bootstrapped/scala/quoted/util/Var.scala b/library/src-bootstrapped/scala/quoted/util/Var.scala index 472e81ea3072..a80de966aedd 100644 --- a/library/src-bootstrapped/scala/quoted/util/Var.scala +++ b/library/src-bootstrapped/scala/quoted/util/Var.scala @@ -34,7 +34,7 @@ object Var { * x * } */ - def apply[T: TypeTag, U: TypeTag](init: Expr[T])(body: Var[T] => Expr[U])(given QuoteContext): Expr[U] = '{ + def apply[T: Type, U: Type](init: Expr[T])(body: Var[T] => Expr[U])(given QuoteContext): Expr[U] = '{ var x = $init ${ body( diff --git a/library/src/scala/internal/Quoted.scala b/library/src/scala/internal/Quoted.scala index 28b507da8b60..197ea7c5c716 100644 --- a/library/src/scala/internal/Quoted.scala +++ b/library/src/scala/internal/Quoted.scala @@ -15,7 +15,7 @@ object Quoted { /** A type quote is desugared by the compiler into a call to this method */ @compileTimeOnly("Illegal reference to `scala.internal.Quoted.typeQuote`") - def typeQuote[T <: AnyKind]: TypeTag[T] = ??? + def typeQuote[T <: AnyKind]: Type[T] = ??? /** A splice in a quoted pattern is desugared by the compiler into a call to this method */ @compileTimeOnly("Illegal reference to `scala.internal.Quoted.patternHole`") diff --git a/library/src/scala/internal/quoted/Matcher.scala b/library/src/scala/internal/quoted/Matcher.scala index feb84973e426..af99fbdc027f 100644 --- a/library/src/scala/internal/quoted/Matcher.scala +++ b/library/src/scala/internal/quoted/Matcher.scala @@ -27,7 +27,7 @@ private[quoted] object Matcher { implicit val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext) val matchings = scrutineeTerm.underlyingArgument =?= patternTerm.underlyingArgument // After matching and doing all subtype checks, we have to aproximate all the type bindings - // that we have found and seal them in a quoted.TypeTag + // that we have found and seal them in a quoted.Type matchings.asOptionOfTuple.map { tup => Tuple.fromArray(tup.toArray.map { // TODO improve performace case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal @@ -47,7 +47,7 @@ private[quoted] object Matcher { implicit val ctx: Context = internal.Context_GADT_setFreshGADTBounds(rootContext) val matchings = scrutineeTypeTree =?= patternTypeTree // After matching and doing all subtype checks, we have to aproximate all the type bindings - // that we have found and seal them in a quoted.TypeTag + // that we have found and seal them in a quoted.Type matchings.asOptionOfTuple.map { tup => Tuple.fromArray(tup.toArray.map { // TODO improve performace case x: SymBinding => internal.Context_GADT_approximation(summon[Context])(x.sym, !x.fromAbove).seal diff --git a/library/src/scala/internal/quoted/TypeTag.scala b/library/src/scala/internal/quoted/Type.scala similarity index 94% rename from library/src/scala/internal/quoted/TypeTag.scala rename to library/src/scala/internal/quoted/Type.scala index 1433095cac87..ca7b2368367c 100644 --- a/library/src/scala/internal/quoted/TypeTag.scala +++ b/library/src/scala/internal/quoted/Type.scala @@ -2,7 +2,7 @@ package scala.internal.quoted import scala.quoted._ -object TypeTag { +object Type { /** Pattern matches an the scrutineeType against the patternType and returns a tuple * with the matched holes if successful. @@ -17,7 +17,7 @@ object TypeTag { * @param qctx the current QuoteContext * @return None if it did not match, `Some(tup)` if it matched where `tup` contains `Type[Ti]`` */ - def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: TypeTag[_])(implicit patternType: TypeTag[_], + def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: Type[_])(implicit patternType: Type[_], hasTypeSplices: Boolean, qctx: QuoteContext): Option[Tup] = { import qctx.tasty.{_, given} new Matcher.QuoteMatcher[qctx.type].typeTreeMatch(scrutineeType.unseal, patternType.unseal, hasTypeSplices).asInstanceOf[Option[Tup]] diff --git a/library/src-non-bootstrapped/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala similarity index 98% rename from library/src-non-bootstrapped/scala/quoted/Expr.scala rename to library/src/scala/quoted/Expr.scala index fc2abec663e6..d533ac680f0f 100644 --- a/library/src-non-bootstrapped/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -163,16 +163,15 @@ package quoted { case Seq('{ $x1: $t1 }, '{ $x2: $t2 }, '{ $x3: $t3 }, '{ $x4: $t4 }, '{ $x5: $t5 }, '{ $x6: $t6 }, '{ $x7: $t7 }, '{ $x8: $t8 }, '{ $x9: $t9 }, '{ $x10: $t10 }, '{ $x11: $t11 }, '{ $x12: $t12 }, '{ $x13: $t13 }, '{ $x14: $t14 }, '{ $x15: $t15 }, '{ $x16: $t16 }, '{ $x17: $t17 }, '{ $x18: $t18 }, '{ $x19: $t19 }, '{ $x20: $t20 }, '{ $x21: $t21 }, '{ $x22: $t22 }) => '{ Tuple22($x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21, $x22) } case _ => - given Type[Any] = ('[Any]).asInstanceOf[Type[Any]] '{ Tuple.fromIArray(IArray(${ofSeq(seq)}: _*)) } } } /** Given a tuple of the form `(Expr[A1], ..., Expr[An])`, outputs a tuple `Expr[(A1, ..., An)]`. */ - def ofTuple[T <: Tuple : Tuple.IsMappedBy[Expr]](tup: T) (given qctx: QuoteContext): Expr[Tuple.InverseMap[T, Expr]] = { + 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).asInstanceOf[Expr[Tuple.InverseMap[T, 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 f01abc81c6dd..6831663e4a0f 100644 --- a/library/src/scala/quoted/QuoteContext.scala +++ b/library/src/scala/quoted/QuoteContext.scala @@ -17,7 +17,7 @@ class QuoteContext(val tasty: scala.tasty.Reflection) { expr.unseal.show(syntaxHighlight) } - def show(tpe: TypeTag[_], syntaxHighlight: SyntaxHighlight): String = { + def show(tpe: Type[_], syntaxHighlight: SyntaxHighlight): String = { import tasty.{_, given} tpe.unseal.show(syntaxHighlight) } diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala new file mode 100644 index 000000000000..73ae4144e0ab --- /dev/null +++ b/library/src/scala/quoted/Type.scala @@ -0,0 +1,78 @@ +package scala + +package quoted { + import scala.quoted.show.SyntaxHighlight + + sealed trait Type[T <: AnyKind] { + type `$splice` = T + + /** Show a source code like representation of this type without syntax highlight */ + def show(given qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) + + /** Show a source code like representation of this type */ + def show(syntaxHighlight: SyntaxHighlight)(given qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) + + } + + /** Some basic type tags, currently incomplete */ + object Type { + + given UnitTag(given qctx: QuoteContext): Type[Unit] = { + import qctx.tasty.{_, given} + defn.UnitType.seal.asInstanceOf[quoted.Type[Unit]] + } + + given BooleanTag(given qctx: QuoteContext): Type[Boolean] = { + import qctx.tasty.{_, given} + defn.BooleanType.seal.asInstanceOf[quoted.Type[Boolean]] + } + + given ByteTag(given qctx: QuoteContext): Type[Byte] = { + import qctx.tasty.{_, given} + defn.ByteType.seal.asInstanceOf[quoted.Type[Byte]] + } + + given CharTag(given qctx: QuoteContext): Type[Char] = { + import qctx.tasty.{_, given} + defn.CharType.seal.asInstanceOf[quoted.Type[Char]] + } + + given ShortTag(given qctx: QuoteContext): Type[Short] = { + import qctx.tasty.{_, given} + defn.ShortType.seal.asInstanceOf[quoted.Type[Short]] + } + + given IntTag(given qctx: QuoteContext): Type[Int] = { + import qctx.tasty.{_, given} + defn.IntType.seal.asInstanceOf[quoted.Type[Int]] + } + + given LongTag(given qctx: QuoteContext): Type[Long] = { + import qctx.tasty.{_, given} + defn.LongType.seal.asInstanceOf[quoted.Type[Long]] + } + + given FloatTag(given qctx: QuoteContext): Type[Float] = { + import qctx.tasty.{_, given} + defn.FloatType.seal.asInstanceOf[quoted.Type[Float]] + } + + given DoubleTag(given qctx: QuoteContext): Type[Double] = { + import qctx.tasty.{_, given} + defn.DoubleType.seal.asInstanceOf[quoted.Type[Double]] + } + + } + +} + +package internal { + package quoted { + + /** An Type backed by a tree */ + final class TreeType[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quoted.Type[Any] { + override def toString: String = s"Type()" + } + + } +} diff --git a/library/src/scala/quoted/TypeTag.scala b/library/src/scala/quoted/TypeTag.scala deleted file mode 100644 index 925017deb18b..000000000000 --- a/library/src/scala/quoted/TypeTag.scala +++ /dev/null @@ -1,82 +0,0 @@ -package scala - -package quoted { - import scala.quoted.show.SyntaxHighlight - - sealed trait TypeTag[T <: AnyKind] { - type `$splice` = T - - /** Show a source code like representation of this type without syntax highlight */ - def show(given qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) - - /** Show a source code like representation of this type */ - def show(syntaxHighlight: SyntaxHighlight)(given qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) - - } - - // TODO remove after reference compiler update - @deprecated("Replaced by scala.quoted.TypeTag", "") - sealed trait Type[T <: AnyKind] extends TypeTag[T] - - /** Some basic type tags, currently incomplete */ - object TypeTag { - - given UnitTag(given qctx: QuoteContext): TypeTag[Unit] = { - import qctx.tasty.{_, given} - defn.UnitType.seal.asInstanceOf[TypeTag[Unit]] - } - - given BooleanTag(given qctx: QuoteContext): TypeTag[Boolean] = { - import qctx.tasty.{_, given} - defn.BooleanType.seal.asInstanceOf[TypeTag[Boolean]] - } - - given ByteTag(given qctx: QuoteContext): TypeTag[Byte] = { - import qctx.tasty.{_, given} - defn.ByteType.seal.asInstanceOf[TypeTag[Byte]] - } - - given CharTag(given qctx: QuoteContext): TypeTag[Char] = { - import qctx.tasty.{_, given} - defn.CharType.seal.asInstanceOf[TypeTag[Char]] - } - - given ShortTag(given qctx: QuoteContext): TypeTag[Short] = { - import qctx.tasty.{_, given} - defn.ShortType.seal.asInstanceOf[TypeTag[Short]] - } - - given IntTag(given qctx: QuoteContext): TypeTag[Int] = { - import qctx.tasty.{_, given} - defn.IntType.seal.asInstanceOf[TypeTag[Int]] - } - - given LongTag(given qctx: QuoteContext): TypeTag[Long] = { - import qctx.tasty.{_, given} - defn.LongType.seal.asInstanceOf[TypeTag[Long]] - } - - given FloatTag(given qctx: QuoteContext): TypeTag[Float] = { - import qctx.tasty.{_, given} - defn.FloatType.seal.asInstanceOf[TypeTag[Float]] - } - - given DoubleTag(given qctx: QuoteContext): TypeTag[Double] = { - import qctx.tasty.{_, given} - defn.DoubleType.seal.asInstanceOf[TypeTag[Double]] - } - - } - -} - -package internal { - package quoted { - - /** An Type backed by a tree */ - final class TreeType[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quoted.Type[Any] { - override def toString: String = s"Type()" - } - - } -} diff --git a/library/src/scala/quoted/ValueOfExpr.scala b/library/src/scala/quoted/ValueOfExpr.scala index bc6b7ba2390a..c094297a1d78 100644 --- a/library/src/scala/quoted/ValueOfExpr.scala +++ b/library/src/scala/quoted/ValueOfExpr.scala @@ -1,6 +1,6 @@ package scala.quoted -/** A typeclass for types that can be turned from a `scala.quoted.Expr[T]` to a `T` */ +/** A typeclass for types that can be turned from a `quoted.Expr[T]` to a `T` */ trait ValueOfExpr[T] { /** Return the value of the expression. diff --git a/library/src/scala/quoted/matching/package.scala b/library/src/scala/quoted/matching/package.scala index 72a9ada5f65e..fad5fa0ed2d1 100644 --- a/library/src/scala/quoted/matching/package.scala +++ b/library/src/scala/quoted/matching/package.scala @@ -10,7 +10,7 @@ package object matching { * @param tpe quoted type of the implicit parameter * @param qctx current context */ - def searchImplicitExpr[T](given tpe: TypeTag[T], qctx: QuoteContext): Option[Expr[T]] = { + def searchImplicitExpr[T](given tpe: Type[T], qctx: QuoteContext): Option[Expr[T]] = { import qctx.tasty.{_, given} searchImplicit(tpe.unseal.tpe) match { case IsImplicitSearchSuccess(iss) => Some(iss.tree.seal.asInstanceOf[Expr[T]]) diff --git a/library/src/scala/runtime/quoted/Unpickler.scala b/library/src/scala/runtime/quoted/Unpickler.scala index 6953517a864e..2d2b558cea3e 100644 --- a/library/src/scala/runtime/quoted/Unpickler.scala +++ b/library/src/scala/runtime/quoted/Unpickler.scala @@ -1,13 +1,13 @@ package scala.runtime.quoted // TODO move to scala.internal.quoted -import scala.quoted.{Expr, QuoteContext, TypeTag} +import scala.quoted.{Expr, QuoteContext, Type} /** Provides methods to unpickle `Expr` and `Type` trees. */ object Unpickler { type PickledQuote = List[String] - type PickledExprArgs = Seq[Seq[Any] => (((given QuoteContext) => Expr[Any]) | TypeTag[_])] - type PickledTypeArgs = Seq[Seq[Any] => TypeTag[_]] + type PickledExprArgs = Seq[Seq[Any] => (((given QuoteContext) => Expr[Any]) | Type[_])] + type PickledTypeArgs = Seq[Seq[Any] => Type[_]] /** Unpickle `repr` which represents a pickled `Expr` tree, * replacing splice nodes with `args` @@ -18,8 +18,8 @@ object Unpickler { /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` */ - def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): (given QuoteContext) => TypeTag[T] = - summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[TypeTag[T]] + def unpickleType[T](repr: PickledQuote, args: PickledTypeArgs): (given QuoteContext) => Type[T] = + summon[QuoteContext].tasty.internal.unpickleType(repr, args).asInstanceOf[Type[T]] } diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 8d3feb12e1d6..aa11d80feb31 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -1,6 +1,6 @@ package scala.tasty -import scala.quoted.{QuoteContext, TypeTag} +import scala.quoted.QuoteContext import scala.tasty.reflect._ class Reflection(private[scala] val internal: CompilerInterface) @@ -24,7 +24,7 @@ class Reflection(private[scala] val internal: CompilerInterface) with TreeUtils with TypeOrBoundsOps { self => - def typeOf[T: TypeTag]: Type = - implicitly[TypeTag[T]].unseal.tpe + def typeOf[T: scala.quoted.Type]: Type = + implicitly[scala.quoted.Type[T]].unseal.tpe } diff --git a/library/src/scala/tasty/reflect/CompilerInterface.scala b/library/src/scala/tasty/reflect/CompilerInterface.scala index f18ff357e8ef..1fa05958fbbb 100644 --- a/library/src/scala/tasty/reflect/CompilerInterface.scala +++ b/library/src/scala/tasty/reflect/CompilerInterface.scala @@ -1,6 +1,6 @@ package scala.tasty.reflect // TODO move to scala.internal.tasty.reflect -import scala.quoted.{Expr, QuoteContext, TypeTag} +import scala.quoted.QuoteContext import scala.tasty.Reflection import scala.runtime.quoted.Unpickler @@ -124,12 +124,12 @@ trait CompilerInterface { /** Unpickle `repr` which represents a pickled `Expr` tree, * replacing splice nodes with `args` */ - def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): Expr[_] + def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[_] /** Unpickle `repr` which represents a pickled `Type` tree, * replacing splice nodes with `args` */ - def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): TypeTag[_] + def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[_] // // CONTEXT @@ -1310,21 +1310,21 @@ trait CompilerInterface { // QUOTED SEAL/UNSEAL // - /** View this expression `scala.quoted.Expr[_]` as a `Term` */ - def QuotedExpr_unseal(self: Expr[_])(given ctx: Context): Term + /** View this expression `quoted.Expr[_]` as a `Term` */ + def QuotedExpr_unseal(self: scala.quoted.Expr[_])(given ctx: Context): Term - /** Checked cast to a `scala.quoted.Expr[U]` */ - def QuotedExpr_cast[U](self: Expr[_])(given tp: TypeTag[U], ctx: Context): Expr[U] + /** Checked cast to a `quoted.Expr[U]` */ + def QuotedExpr_cast[U](self: scala.quoted.Expr[_])(given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] - /** View this expression `scala.quoted.TypeTag[T]` as a `TypeTree` */ - def QuotedType_unseal(self: TypeTag[_])(given ctx: Context): TypeTree + /** View this expression `quoted.Type[T]` as a `TypeTree` */ + def QuotedType_unseal(self: scala.quoted.Type[_])(given ctx: Context): TypeTree - /** Convert `Term` to an `scala.quoted.Expr[Any]` */ - def QuotedExpr_seal(self: Term)(given ctx: Context): Expr[Any] + /** Convert `Term` to an `quoted.Expr[Any]` */ + def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] - /** Convert `Type` to an `scala.quoted.TypeTag[_]` */ - def QuotedType_seal(self: Type)(given ctx: Context): TypeTag[_] + /** Convert `Type` to an `quoted.Type[_]` */ + def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[_] // // DEFINITIONS diff --git a/library/src/scala/tasty/reflect/QuotedOps.scala b/library/src/scala/tasty/reflect/QuotedOps.scala index 16579ea78a64..8b7b97f5992f 100644 --- a/library/src/scala/tasty/reflect/QuotedOps.scala +++ b/library/src/scala/tasty/reflect/QuotedOps.scala @@ -1,35 +1,33 @@ package scala.tasty.reflect -import scala.quoted._ - /** Extension methods on scala.quoted.{Expr|Type} to convert to scala.tasty.Tasty objects */ trait QuotedOps extends Core { - implicit class QuotedExprAPI[T](expr: Expr[T]) { - /** View this expression `scala.quoted.Expr[T]` as a `Term` */ + implicit class QuotedExprAPI[T](expr: scala.quoted.Expr[T]) { + /** View this expression `quoted.Expr[T]` as a `Term` */ def unseal(given ctx: Context): Term = internal.QuotedExpr_unseal(expr) - /** Checked cast to a `scala.quoted.Expr[U]` */ - def cast[U: TypeTag](given ctx: Context): Expr[U] = // TODO use TypeTag after rebootstrap + /** Checked cast to a `quoted.Expr[U]` */ + def cast[U: scala.quoted.Type](given ctx: Context): scala.quoted.Expr[U] = internal.QuotedExpr_cast[U](expr) } - implicit class QuotedTypeAPI[T <: AnyKind](tpe: TypeTag[T]) { - /** View this expression `scala.quoted.TypeTag[T]` as a `TypeTree` */ + implicit class QuotedTypeAPI[T <: AnyKind](tpe: scala.quoted.Type[T]) { + /** View this expression `quoted.Type[T]` as a `TypeTree` */ def unseal(given ctx: Context): TypeTree = internal.QuotedType_unseal(tpe) } implicit class TermToQuotedAPI(term: Term) { - /** Convert `Term` to an `scala.quoted.Expr[Any]` */ - def seal(given ctx: Context): Expr[Any] = + /** Convert `Term` to an `quoted.Expr[Any]` */ + def seal(given ctx: Context): scala.quoted.Expr[Any] = internal.QuotedExpr_seal(term) } implicit class TypeToQuotedAPI(tpe: Type) { - /** Convert `Type` to an `scala.quoted.TypeTag[_]` */ - def seal(given ctx: Context): TypeTag[_] = + /** Convert `Type` to an `quoted.Type[_]` */ + def seal(given ctx: Context): scala.quoted.Type[_] = internal.QuotedType_seal(tpe) } } diff --git a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala index e72cc058e9fe..032418ed6925 100644 --- a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala +++ b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala @@ -5,7 +5,7 @@ trait TypeOrBoundsOps extends Core { // ----- Types ---------------------------------------------------- - def typeOf[T: scala.quoted.TypeTag]: Type + def typeOf[T: scala.quoted.Type]: Type given (self: Type) { def =:=(that: Type)(given ctx: Context): Boolean = internal.`Type_=:=`(self)(that) diff --git a/staging/src/scala/quoted/staging/QuoteCompiler.scala b/staging/src/scala/quoted/staging/QuoteCompiler.scala index 9e7063d7ea0a..620f924ae0ea 100644 --- a/staging/src/scala/quoted/staging/QuoteCompiler.scala +++ b/staging/src/scala/quoted/staging/QuoteCompiler.scala @@ -23,7 +23,7 @@ import dotty.tools.io.{Path, VirtualFile} import scala.annotation.tailrec import scala.concurrent.Promise -import scala.quoted.{Expr, QuoteContext, TypeTag} +import scala.quoted.{Expr, QuoteContext, Type} /** Compiler that takes the contents of a quoted expression `expr` and produces * a class file with `class ' { def apply: Object = expr }`. @@ -46,7 +46,7 @@ private class QuoteCompiler extends Compiler { def outputClassName: TypeName = "Generated$Code$From$Quoted".toTypeName - /** Frontend that receives a scala.quoted.Expr or scala.quoted.TypeTag as input */ + /** Frontend that receives a scala.quoted.Expr or scala.quoted.Type as input */ class QuotedFrontend extends Phase { import tpd._ diff --git a/staging/test-resources/repl-staging/i6263 b/staging/test-resources/repl-staging/i6263 index e83675dff72b..2dd3e41cc695 100644 --- a/staging/test-resources/repl-staging/i6263 +++ b/staging/test-resources/repl-staging/i6263 @@ -2,8 +2,8 @@ scala> import quoted._ scala> import quoted.staging._ scala> implicit def toolbox: Toolbox = Toolbox.make(getClass.getClassLoader) def toolbox: quoted.staging.Toolbox -scala> def fn[T : TypeTag](v : T) = println("ok") -def fn[T](v: T)(implicit evidence$1: quoted.TypeTag[T]): Unit +scala> def fn[T : Type](v : T) = println("ok") +def fn[T](v: T)(implicit evidence$1: quoted.Type[T]): Unit scala> withQuoteContext { fn("foo") } ok scala> withQuoteContext { fn((1,2)) } diff --git a/tests/neg-staging/i5941/macro_1.scala b/tests/neg-staging/i5941/macro_1.scala index 2163af3ce169..5ec3d910df6a 100644 --- a/tests/neg-staging/i5941/macro_1.scala +++ b/tests/neg-staging/i5941/macro_1.scala @@ -11,7 +11,7 @@ object Lens { def set(t: T, s: S): S = _set(t)(s) } - def impl[S: TypeTag, T: TypeTag](getter: Expr[S => T])(given qctx: QuoteContext): Expr[Lens[S, T]] = { + 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.{_, given} import util._ diff --git a/tests/neg/i4350.scala b/tests/neg/i4350.scala index 66a5a5e230b1..fb40aca02715 100644 --- a/tests/neg/i4350.scala +++ b/tests/neg/i4350.scala @@ -1,4 +1,4 @@ -import scala.quoted.TypeTag +import scala.quoted.Type class Foo[T] { '{null.asInstanceOf[T]} // error diff --git a/tests/neg/i4493-b.scala b/tests/neg/i4493-b.scala index 457881ee2bfd..235f14c0a4a9 100644 --- a/tests/neg/i4493-b.scala +++ b/tests/neg/i4493-b.scala @@ -1,7 +1,7 @@ class Index[K] object Index { inline def succ[K](x: K): Unit = ${ - implicit val t: quoted.TypeTag[K] = '[K] // error + implicit val t: quoted.Type[K] = '[K] // error '{new Index[K]} } } diff --git a/tests/neg/i4493.scala b/tests/neg/i4493.scala index 7b9ed9fb9999..852ac0d44d54 100644 --- a/tests/neg/i4493.scala +++ b/tests/neg/i4493.scala @@ -1,7 +1,7 @@ class Index[K] object Index { inline def succ[K]: Unit = ${ - implicit val t: scala.quoted.TypeTag[K] = '[K] // error + implicit val t: quoted.Type[K] = '[K] // error '{new Index[K]} } } diff --git a/tests/neg/i6530b.scala b/tests/neg/i6530b.scala index 666ad7bf6c7f..b60bc7c5c548 100644 --- a/tests/neg/i6530b.scala +++ b/tests/neg/i6530b.scala @@ -1,12 +1,12 @@ import scala.quoted._ object Foo { def program(given QuoteContext) = '{ - val tpe: TypeTag[Int] = ??? - val expr: Expr[Int] = ??? + val tpe: quoted.Type[Int] = ??? + val expr: quoted.Expr[Int] = ??? - val a: Expr[Int] = ${ '[Int] } // error - val b: Expr[Int] = '{ $tpe } // error + val a: quoted.Expr[Int] = ${ '[Int] } // error + val b: quoted.Expr[Int] = '{ $tpe } // error val c: ${ '{ 43 } } = ??? // error - val d: TypeTag[Int] = '[ $expr ] // error + val d: quoted.Type[Int] = '[ $expr ] // error } } diff --git a/tests/neg/i7121.scala b/tests/neg/i7121.scala index 778cd2fa4583..dc7dfcdb0f2f 100644 --- a/tests/neg/i7121.scala +++ b/tests/neg/i7121.scala @@ -1,7 +1,7 @@ import scala.quoted._ class annot1[T](x: Expr[T]) extends scala.annotation.Annotation -class annot2[T: TypeTag](x: T) extends scala.annotation.Annotation +class annot2[T: Type](x: T) extends scala.annotation.Annotation class Test()(implicit qtx: QuoteContext) { @annot1('{4}) // error diff --git a/tests/neg/i7323.scala b/tests/neg/i7323.scala index 5614355bf264..4fdaefc7f14d 100644 --- a/tests/neg/i7323.scala +++ b/tests/neg/i7323.scala @@ -1,3 +1,3 @@ trait Foo { type X } -def f[T](given scala.quoted.TypeTag[T]) = ??? +def f[T](given scala.quoted.Type[T]) = ??? def g(m: Foo) = f[m.X] // error \ No newline at end of file diff --git a/tests/neg/quote-1.scala b/tests/neg/quote-1.scala index caa8eccfcac7..71749010e37e 100644 --- a/tests/neg/quote-1.scala +++ b/tests/neg/quote-1.scala @@ -2,11 +2,11 @@ import scala.quoted._ class Test { - def f[T](t: TypeTag[T], x: Expr[T])(given QuoteContext) = '{ + def f[T](t: Type[T], x: Expr[T])(given QuoteContext) = '{ val z2 = $x // error // error: wrong staging level } - def g[T](implicit t: TypeTag[T], x: Expr[T], qctx: QuoteContext) = '{ + def g[T](implicit t: Type[T], x: Expr[T], qctx: QuoteContext) = '{ val z2 = $x // ok } diff --git a/tests/neg/quotedPatterns-5.scala b/tests/neg/quotedPatterns-5.scala index e12c8da6b115..d813edb1639c 100644 --- a/tests/neg/quotedPatterns-5.scala +++ b/tests/neg/quotedPatterns-5.scala @@ -3,7 +3,7 @@ object Test { def test(x: quoted.Expr[Int])(given QuoteContext) = x match { case '{ type $t; poly[$t]($x); 4 } => ??? // error: duplicate pattern variable: $t case '{ type `$t`; poly[`$t`]($x); 4 } => - val tt: TypeTag[_] = t // error + val tt: quoted.Type[_] = t // error ??? case _ => } diff --git a/tests/pos-macros/i4023/Macro_1.scala b/tests/pos-macros/i4023/Macro_1.scala index 555328e65865..34551e3123fc 100644 --- a/tests/pos-macros/i4023/Macro_1.scala +++ b/tests/pos-macros/i4023/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T: TypeTag](x: T): T = ${ impl('x) } + inline def ff[T: Type](x: T): T = ${ impl('x) } def impl[T](x: Expr[T]): Expr[T] = x } diff --git a/tests/pos-macros/i4023b/Macro_1.scala b/tests/pos-macros/i4023b/Macro_1.scala index d4332848052e..195896cc8d8f 100644 --- a/tests/pos-macros/i4023b/Macro_1.scala +++ b/tests/pos-macros/i4023b/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { - inline def ff[T](implicit t: TypeTag[T]): Int = ${ impl[T] } + inline def ff[T](implicit t: Type[T]): Int = ${ impl[T] } def impl[T](given QuoteContext): Expr[Int] = '{4} } diff --git a/tests/pos-macros/i4023c/Macro_1.scala b/tests/pos-macros/i4023c/Macro_1.scala index 0636e458a193..33feeda9e5a8 100644 --- a/tests/pos-macros/i4023c/Macro_1.scala +++ b/tests/pos-macros/i4023c/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff[T](x: T): T = ${ impl('x)('[T], summon[QuoteContext]) } - def impl[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = '{ $x: $t } + def impl[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ $x: $t } } diff --git a/tests/pos-macros/i6210/Macros_1.scala b/tests/pos-macros/i6210/Macros_1.scala index 4fa36ac9f51a..3ae8e0a11344 100644 --- a/tests/pos-macros/i6210/Macros_1.scala +++ b/tests/pos-macros/i6210/Macros_1.scala @@ -4,7 +4,7 @@ object Macro { inline def test[A, B]: Any = ${ impl[A, B] } - def impl[A : TypeTag, B : TypeTag](given QuoteContext): Expr[Any] = { + def impl[A : Type, B : Type](given QuoteContext): Expr[Any] = { val t = '[Map[A, B]] '{ new Object().asInstanceOf[$t] diff --git a/tests/pos-macros/macro-with-type/Macro_1.scala b/tests/pos-macros/macro-with-type/Macro_1.scala index a8152d229bcf..6d2e3c1380a2 100644 --- a/tests/pos-macros/macro-with-type/Macro_1.scala +++ b/tests/pos-macros/macro-with-type/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def ff: Unit = ${impl('[Int])} - def impl(t: TypeTag[Int])(given QuoteContext): Expr[Unit] = '{} + def impl(t: Type[Int])(given QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos-macros/tasty-constant-type/Macro_1.scala b/tests/pos-macros/tasty-constant-type/Macro_1.scala index d80b7f28f947..e78f61ce7ca8 100644 --- a/tests/pos-macros/tasty-constant-type/Macro_1.scala +++ b/tests/pos-macros/tasty-constant-type/Macro_1.scala @@ -6,7 +6,7 @@ object Macro { inline def ff[A <: Int, B <: Int]() <: AddInt[A, B] = ${ impl('[A], '[B]) } - def impl[A <: Int : TypeTag, B <: Int : TypeTag](a: TypeTag[A], b: TypeTag[B])(given qctx: QuoteContext): Expr[AddInt[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.{_, given} val Type.ConstantType(Constant(v1: Int)) = a.unseal.tpe diff --git a/tests/pos/i4350.scala b/tests/pos/i4350.scala index 81c7e70fd4c1..8b2127987bba 100644 --- a/tests/pos/i4350.scala +++ b/tests/pos/i4350.scala @@ -1,5 +1,5 @@ import scala.quoted._ -class Foo[T: TypeTag](given QuoteContext) { +class Foo[T: Type](given QuoteContext) { '{null.asInstanceOf[T]} } diff --git a/tests/pos/i4414.scala b/tests/pos/i4414.scala index ab37ad248c4a..0517942a555b 100644 --- a/tests/pos/i4414.scala +++ b/tests/pos/i4414.scala @@ -3,10 +3,10 @@ import scala.quoted._ object Test { given QuoteContext = ??? - def a[A: TypeTag](): Unit = { + def a[A: Type](): Unit = { b[Expr[A]]() a[A]() } - def b[A: TypeTag](): Unit = ??? + def b[A: Type](): Unit = ??? } diff --git a/tests/pos/i4514.scala b/tests/pos/i4514.scala index e44c32b1cf6b..87283f8c263c 100644 --- a/tests/pos/i4514.scala +++ b/tests/pos/i4514.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Foo { inline def foo[X](x: X): Unit = ${fooImpl('x)} - def fooImpl[X: TypeTag](x: X)(given QuoteContext): Expr[Unit] = '{} + def fooImpl[X: Type](x: X)(given QuoteContext): Expr[Unit] = '{} } diff --git a/tests/pos/i4539b.scala b/tests/pos/i4539b.scala index e6c45cf18565..bf6a16d6ca53 100644 --- a/tests/pos/i4539b.scala +++ b/tests/pos/i4539b.scala @@ -13,10 +13,10 @@ def test(given QuoteContext) = { '[String] } - def bar[T](t: TypeTag[T]) = ??? + def bar[T](t: quoted.Type[T]) = ??? bar('[String]) - class Baz[T](t: TypeTag[T]) + class Baz[T](t: quoted.Type[T]) new Baz('[String]) } diff --git a/tests/pos/i4774a.scala b/tests/pos/i4774a.scala index 20fdaa0de12d..4fa5e5aa0bc0 100644 --- a/tests/pos/i4774a.scala +++ b/tests/pos/i4774a.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = '{ + def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ val y: $t = $x ${loop('y)} } diff --git a/tests/pos/i4774c.scala b/tests/pos/i4774c.scala index 1e29cb092e1b..cbc2bf7be250 100644 --- a/tests/pos/i4774c.scala +++ b/tests/pos/i4774c.scala @@ -2,5 +2,5 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = '{ val y = $x; ${loop('y)} } + def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ val y = $x; ${loop('y)} } } diff --git a/tests/pos/i4774d.scala b/tests/pos/i4774d.scala index f2d5e3e305da..54de29d9e6b7 100644 --- a/tests/pos/i4774d.scala +++ b/tests/pos/i4774d.scala @@ -2,6 +2,6 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = + def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ val y: T = $x; ${loop('y)} } } diff --git a/tests/pos/i4774e.scala b/tests/pos/i4774e.scala index b1f38d3ecb2c..2910c77d3780 100644 --- a/tests/pos/i4774e.scala +++ b/tests/pos/i4774e.scala @@ -2,9 +2,9 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = + def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ def y = $x; ${ loop('y) } } - def loop2[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = + def loop2[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ def y() = $x; ${ loop('{y()}) } } } diff --git a/tests/pos/i4774f.scala b/tests/pos/i4774f.scala index 461e162172ed..d782bfac6ebf 100644 --- a/tests/pos/i4774f.scala +++ b/tests/pos/i4774f.scala @@ -2,9 +2,9 @@ import scala.quoted._ object Test { - def loop[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = + def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ def y: T = $x; ${ loop('y) } } - def loop2[T](x: Expr[T])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[T] = + def loop2[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{ def y(): T = $x; ${ loop2('{y()}) } } } diff --git a/tests/pos/i5954.scala b/tests/pos/i5954.scala index 2471f16b8945..d14c1ddf1076 100644 --- a/tests/pos/i5954.scala +++ b/tests/pos/i5954.scala @@ -9,7 +9,7 @@ object MatcherFactory1 { '{ val a: Any = $self } - def impl2[T: TypeTag](a: MatcherFactory1)(self: Expr[T])(implicit ev: T =:= a.AndNotWord, qctx: QuoteContext) = + def impl2[T: Type](a: MatcherFactory1)(self: Expr[T])(implicit ev: T =:= a.AndNotWord, qctx: QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5954b.scala b/tests/pos/i5954b.scala index 1b7686342e7f..b0cb1ed2eb79 100644 --- a/tests/pos/i5954b.scala +++ b/tests/pos/i5954b.scala @@ -9,7 +9,7 @@ object MatcherFactory1 { '{ val a: Any = $self } - def impl[T: TypeTag](self: Expr[MatcherFactory1#AndNotWord[T]])(given QuoteContext) = + def impl[T: Type](self: Expr[MatcherFactory1#AndNotWord[T]])(given QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5954c.scala b/tests/pos/i5954c.scala index f1db1b06dbe8..5ae67c521628 100644 --- a/tests/pos/i5954c.scala +++ b/tests/pos/i5954c.scala @@ -9,7 +9,7 @@ object MatcherFactory1 { '{ val a: Any = $self } - def impl[T: TypeTag](self: Expr[MatcherFactory1[T]#AndNotWord])(given QuoteContext) = + def impl[T: Type](self: Expr[MatcherFactory1[T]#AndNotWord])(given QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5954d.scala b/tests/pos/i5954d.scala index 0b0870bfed65..ec59abe167a6 100644 --- a/tests/pos/i5954d.scala +++ b/tests/pos/i5954d.scala @@ -9,7 +9,7 @@ object MatcherFactory1 { '{ val a: Any = $self } - def impl2[T: TypeTag](a: MatcherFactory1)(self: Expr[T])(implicit ev: T =:= a.AndNotWord, qctx: QuoteContext) = + def impl2[T: Type](a: MatcherFactory1)(self: Expr[T])(implicit ev: T =:= a.AndNotWord, qctx: QuoteContext) = '{ val a: Any = $self } } diff --git a/tests/pos/i5962.scala b/tests/pos/i5962.scala index 63b9cd7ddcbb..da9a5ccc1c67 100644 --- a/tests/pos/i5962.scala +++ b/tests/pos/i5962.scala @@ -6,7 +6,7 @@ class MatchFactory1[T, S[_]] { object MatcherFactory1 { - def impl[T: TypeTag, S[_], M >: MatchFactory1[T, S] <: MatchFactory1[T, S] : TypeTag](self: Expr[M])(implicit qctx: QuoteContext, tpS: TypeTag[S[T]]) = + def impl[T: Type, S[_], M >: MatchFactory1[T, S] <: MatchFactory1[T, S] : Type](self: Expr[M])(implicit qctx: QuoteContext, tpS: Type[S[T]]) = '{ val a = ${self}; a.f } } diff --git a/tests/pos/i6142.scala b/tests/pos/i6142.scala index 00daa3bd33fa..da099ddc13f8 100644 --- a/tests/pos/i6142.scala +++ b/tests/pos/i6142.scala @@ -3,7 +3,7 @@ import scala.quoted._ object O { def foo(given QuoteContext) = { type T - implicit val _: TypeTag[T] = ??? + implicit val _: scala.quoted.Type[T] = ??? '[List[T]] () } diff --git a/tests/pos/i6588.scala b/tests/pos/i6588.scala index bc3c88c1ef1c..c9ad60584be2 100644 --- a/tests/pos/i6588.scala +++ b/tests/pos/i6588.scala @@ -1,10 +1,8 @@ import scala.quoted._ -inline def foo[T:TypeTag]: Int = 10 +inline def foo[T:Type]: Int = 10 def main = { - given QuoteContext = ??? - type S = Int foo[S] foo[Int] diff --git a/tests/pos/i6997.scala b/tests/pos/i6997.scala index 36f808808c5b..1c3449d0e6af 100644 --- a/tests/pos/i6997.scala +++ b/tests/pos/i6997.scala @@ -1,7 +1,7 @@ import scala.quoted._ class Foo { - def mcrImpl(body: Expr[Any])(given t: TypeTag[_ <: Any])(given ctx: QuoteContext): Expr[Any] = '{ + def mcrImpl(body: Expr[Any])(given t: Type[_ <: Any])(given ctx: QuoteContext): Expr[Any] = '{ val tmp = ???.asInstanceOf[$t] tmp } diff --git a/tests/pos/i7048c.scala b/tests/pos/i7048c.scala index 73fb82a459bb..a00228f85cd6 100644 --- a/tests/pos/i7048c.scala +++ b/tests/pos/i7048c.scala @@ -6,7 +6,7 @@ trait IsExpr { val foo: IsExpr = ??? -def g(e: IsExpr)(given tu: TypeTag[e.Underlying]): Unit = ??? +def g(e: IsExpr)(given tu: Type[e.Underlying]): Unit = ??? def mcrImpl(given QuoteContext): Unit = { g(foo) diff --git a/tests/pos/i7048d.scala b/tests/pos/i7048d.scala index 76cb4bce4a95..e9b5c46cc0a7 100644 --- a/tests/pos/i7048d.scala +++ b/tests/pos/i7048d.scala @@ -6,7 +6,7 @@ trait IsExpr { val foo: IsExpr = ??? -def g(e: IsExpr)(given tu: TypeTag[e.Underlying]): Unit = ??? +def g(e: IsExpr)(given tu: Type[e.Underlying]): Unit = ??? def mcrImpl(given QuoteContext): Unit = { g(foo) diff --git a/tests/pos/i7358.scala b/tests/pos/i7358.scala index e8fc7f17c691..9a20680bed76 100644 --- a/tests/pos/i7358.scala +++ b/tests/pos/i7358.scala @@ -8,9 +8,9 @@ inline def summonT[Tp <: Tuple] <: Tuple = inline erasedValue[Tp] match { case _ : (hd *: tl) => { type H = hd summonFrom { - case given _ : TypeTag[H] => summon[TypeTag[H]] *: summonT[tl] + case given _ : Type[H] => summon[Type[H]] *: summonT[tl] } } } -def test[T : TypeTag] = summonT[Tuple1[List[T]]] +def test[T : Type] = summonT[Tuple1[List[T]]] diff --git a/tests/pos/quote-1.scala b/tests/pos/quote-1.scala index 4f5243aaa6ff..8265f3a2fcde 100644 --- a/tests/pos/quote-1.scala +++ b/tests/pos/quote-1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Test { given QuoteContext = ??? - def f[T](x: Expr[T])(implicit t: TypeTag[T]) = '{ + def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val y: $t = $x val z = $x } @@ -11,6 +11,6 @@ object Test { f('{2})('[Int]) f('{ true })('[Boolean]) - def g(es: Expr[String], t: TypeTag[String]) = + def g(es: Expr[String], t: Type[String]) = f('{ ($es + "!") :: Nil })('[List[$t]]) } diff --git a/tests/pos/quote-bind-T.scala b/tests/pos/quote-bind-T.scala index aec62f731ee3..1b882825b1d0 100644 --- a/tests/pos/quote-bind-T.scala +++ b/tests/pos/quote-bind-T.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - def matchX[T](x: Expr[T])(given TypeTag[T], QuoteContext): Expr[T] = '{ + def matchX[T](x: Expr[T])(given Type[T], QuoteContext): Expr[T] = '{ $x match { case y: T => y } diff --git a/tests/pos/quote-liftable-list-2.scala b/tests/pos/quote-liftable-list-2.scala index 41dea21c29ed..8071e5771fee 100644 --- a/tests/pos/quote-liftable-list-2.scala +++ b/tests/pos/quote-liftable-list-2.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - implicit def ListIsLiftableOr[T: TypeTag, U: TypeTag]: Liftable[List[T | U]] = new { + implicit def ListIsLiftableOr[T: Type, U: Type]: Liftable[List[T | U]] = new { def toExpr(xs: List[T | U]) = '{ Nil: List[T | U] } } diff --git a/tests/pos/quote-liftable-list-3.scala b/tests/pos/quote-liftable-list-3.scala index 74aaf04afcdd..4118df7d92a7 100644 --- a/tests/pos/quote-liftable-list-3.scala +++ b/tests/pos/quote-liftable-list-3.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - implicit def ListIsLiftableAnd[T: TypeTag, U: TypeTag]: Liftable[List[T & U]] = new { + implicit def ListIsLiftableAnd[T: Type, U: Type]: Liftable[List[T & U]] = new { def toExpr(xs: List[T & U]) = '{ Nil: List[T & U] } } diff --git a/tests/pos/quote-liftable-list.scala b/tests/pos/quote-liftable-list.scala index 8cf2ffb26e82..c2c4af24341b 100644 --- a/tests/pos/quote-liftable-list.scala +++ b/tests/pos/quote-liftable-list.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Test { - implicit def ListIsLiftable[T: Liftable: TypeTag]: Liftable[List[T]] = new { + implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { def toExpr(xs: List[T]) = '{ Nil: List[T] } } diff --git a/tests/pos/quote-liftable.scala b/tests/pos/quote-liftable.scala index 536994a5a9a1..2f74bb7f86ce 100644 --- a/tests/pos/quote-liftable.scala +++ b/tests/pos/quote-liftable.scala @@ -19,7 +19,7 @@ def test(given QuoteContext) = { if (b) '{true} else '{false} } - implicit def ListIsLiftable[T: Liftable: TypeTag]: Liftable[List[T]] = new { + implicit def ListIsLiftable[T: Liftable: Type]: Liftable[List[T]] = new { def toExpr(xs: List[T]) = xs match { case x :: xs1 => '{ ${ Expr(x) } :: ${ toExpr(xs1) } } case Nil => '{Nil: List[T]} diff --git a/tests/pos/quote-matching-implicit-types.scala b/tests/pos/quote-matching-implicit-types.scala index 0f204e76d601..4cc211a2e6cc 100644 --- a/tests/pos/quote-matching-implicit-types.scala +++ b/tests/pos/quote-matching-implicit-types.scala @@ -11,6 +11,6 @@ object Foo { def foo[T](t: T): Unit = () - def bar[T: TypeTag](t: Expr[T]): Boolean = true + def bar[T: Type](t: Expr[T]): Boolean = true } diff --git a/tests/pos/quoted-pattern-type.scala b/tests/pos/quoted-pattern-type.scala index 5fb0b28fede5..67a9369d26e9 100644 --- a/tests/pos/quoted-pattern-type.scala +++ b/tests/pos/quoted-pattern-type.scala @@ -3,7 +3,7 @@ import scala.tasty.Reflection object Lib { - def impl[T: TypeTag](arg: Expr[T])(given QuoteContext): Expr[T] = { + def impl[T: Type](arg: Expr[T])(given QuoteContext): Expr[T] = { arg match { case e @ '{ $x: Boolean } => e: Expr[T & Boolean] diff --git a/tests/pos/quotedPatterns.scala b/tests/pos/quotedPatterns.scala index 4398778d4c20..0aa5589e5798 100644 --- a/tests/pos/quotedPatterns.scala +++ b/tests/pos/quotedPatterns.scala @@ -34,7 +34,7 @@ object Test { case '{ poly[$t]($x); 4 } => ??? case '{ poly[${Foo(t)}]($x); 4 } => ??? case '{ type $X; poly[`$X`]($x); 4 } => ??? - case '{ type $t; poly[${Foo(x: TypeTag[`$t`])}]($x); 4 } => ??? + case '{ type $t; poly[${Foo(x: quoted.Type[`$t`])}]($x); 4 } => ??? case '{ type $T; val x: `$T` = $a; val y: `$T` = x; 1 } => ??? case '{ type $t <: AnyRef; val x: `$t` = $a; val y: `$t` = x; 1 } => ??? case _ => '{1} @@ -43,6 +43,6 @@ object Test { def poly[T](x: T): Unit = () object Foo { - def unapply[T](arg: TypeTag[T]): Option[TypeTag[T]] = Some(arg) + def unapply[T](arg: quoted.Type[T]): Option[quoted.Type[T]] = Some(arg) } } \ No newline at end of file diff --git a/tests/pos/typetags.scala b/tests/pos/typetags.scala index f62f918dec35..38ab45b09c12 100644 --- a/tests/pos/typetags.scala +++ b/tests/pos/typetags.scala @@ -2,10 +2,10 @@ import scala.quoted._ object Test { - def f[T: TypeTag](given QuoteContext) = { - implicitly[TypeTag[Int]] - implicitly[TypeTag[List[Int]]] - implicitly[TypeTag[T]] - implicitly[TypeTag[List[T]]] + def f[T: Type](given QuoteContext) = { + implicitly[Type[Int]] + implicitly[Type[List[Int]]] + implicitly[Type[T]] + implicitly[Type[List[T]]] } } diff --git a/tests/run-macros/gestalt-optional-staging/Macro_1.scala b/tests/run-macros/gestalt-optional-staging/Macro_1.scala index 81ad244f2e72..2ed4186ea888 100644 --- a/tests/run-macros/gestalt-optional-staging/Macro_1.scala +++ b/tests/run-macros/gestalt-optional-staging/Macro_1.scala @@ -17,12 +17,12 @@ final class Optional[+A >: Null](val value: A) extends AnyVal { object Optional { // FIXME fix issue #5097 and enable private - /*private*/ def getOrElseImpl[T >: Null : TypeTag](opt: Expr[Optional[T]], alt: Expr[T])(given QuoteContext): Expr[T] = '{ + /*private*/ def getOrElseImpl[T >: Null : Type](opt: Expr[Optional[T]], alt: Expr[T])(given QuoteContext): Expr[T] = '{ if ($opt.isEmpty) $alt else $opt.value } // FIXME fix issue #5097 and enable private - /*private*/ def mapImpl[A >: Null : TypeTag, B >: Null : TypeTag](opt: Expr[Optional[A]], f: Expr[A => B])(given QuoteContext): Expr[Optional[B]] = '{ + /*private*/ def mapImpl[A >: Null : Type, B >: Null : Type](opt: Expr[Optional[A]], f: Expr[A => B])(given QuoteContext): Expr[Optional[B]] = '{ if ($opt.isEmpty) new Optional(null) else new Optional(${Expr.betaReduce(f)('{$opt.value})}) } 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 ceac125e4f90..b51e450fab04 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -6,28 +6,28 @@ import scala.quoted._ object TypeToolbox { /** are the two types equal? */ inline def =:=[A, B]: Boolean = ${tpEqImpl('[A], '[B])} - private def tpEqImpl[A, B](a: TypeTag[A], b: TypeTag[B])(given qctx: QuoteContext): Expr[Boolean] = { + private def tpEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { 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: TypeTag[A], b: TypeTag[B])(given qctx: QuoteContext): Expr[Boolean] = { + private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Boolean] = { 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: TypeTag[_])(given qctx: QuoteContext): Expr[Boolean] = { + private def typeOfImpl(a: Expr[_], expected: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { 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: TypeTag[_])(given qctx: QuoteContext): Expr[Boolean] = { + private def isCaseClassImpl(tp: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} val sym = tp.unseal.symbol Expr(sym.isClassDef && sym.flags.is(Flags.Case)) @@ -35,66 +35,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: TypeTag[_])(given qctx: QuoteContext): Expr[List[String]] = { + private def caseFieldsImpl(tp: Type[_])(given qctx: QuoteContext): Expr[List[String]] = { 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: TypeTag[_], mem: String)(given qctx: QuoteContext): Expr[String] = { + private def fieldInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[String] = { 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: TypeTag[_])(given qctx: QuoteContext): Expr[Seq[String]] = { + private def fieldsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { 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: TypeTag[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { + private def methodInImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty.{_, given} Expr(t.unseal.symbol.classMethod(mem).map(_.name)) } inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} - private def methodsInImpl(t: TypeTag[_])(given qctx: QuoteContext): Expr[Seq[String]] = { + private def methodsInImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { 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: TypeTag[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { + private def methodImpl(t: Type[_], mem: String)(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty.{_, given} Expr(t.unseal.symbol.method(mem).map(_.name)) } inline def methods[T]: Seq[String] = ${methodsImpl('[T])} - private def methodsImpl(t: TypeTag[_])(given qctx: QuoteContext): Expr[Seq[String]] = { + private def methodsImpl(t: Type[_])(given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty.{_, given} Expr(t.unseal.symbol.methods.map(_.name)) } inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} - private def typeTagImpl(tp: TypeTag[_])(given qctx: QuoteContext): Expr[String] = { + private def typeTagImpl(tp: Type[_])(given qctx: QuoteContext): Expr[String] = { 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: TypeTag[_], t2: TypeTag[_])(given qctx: QuoteContext): Expr[Boolean] = { + private def companionImpl(t1: Type[_], t2: Type[_])(given qctx: QuoteContext): Expr[Boolean] = { 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: TypeTag[_])(given qctx: QuoteContext): Expr[String] = { + private def companionNameImpl(tp: Type[_])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty.{_, given} val sym = tp.unseal.symbol val companionClass = diff --git a/tests/run-macros/i4515/Macro_1.scala b/tests/run-macros/i4515/Macro_1.scala index ab463d73c2ab..74808f079207 100644 --- a/tests/run-macros/i4515/Macro_1.scala +++ b/tests/run-macros/i4515/Macro_1.scala @@ -1,5 +1,5 @@ import scala.quoted._ object Macro { inline def foo[X](x: X): Unit = ${fooImpl('x)} - def fooImpl[X: TypeTag](x: Expr[X])(given QuoteContext): Expr[Unit] = '{} + def fooImpl[X: quoted.Type](x: Expr[X])(given QuoteContext): Expr[Unit] = '{} } diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index 21f21b762b13..ff41ce1a77ab 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -11,7 +11,7 @@ object Lens { def set(t: T, s: S): S = _set(t)(s) } - def impl[S: TypeTag, T: TypeTag](getter: Expr[S => T])(given qctx: QuoteContext): Expr[Lens[S, T]] = { + def impl[S: Type, T: Type](getter: Expr[S => T])(given qctx: QuoteContext): Expr[Lens[S, T]] = { import qctx.tasty.{_, given} import util._ @@ -84,7 +84,7 @@ object Iso { def to(s: S): A = _to(s) } - def impl[S: TypeTag, A: TypeTag](given qctx: QuoteContext): Expr[Iso[S, A]] = { + def impl[S: Type, A: Type](given qctx: QuoteContext): Expr[Iso[S, A]] = { import qctx.tasty.{_, given} import util._ @@ -123,7 +123,7 @@ object Iso { } } - def implUnit[S: TypeTag](given qctx: QuoteContext): Expr[Iso[S, 1]] = { + def implUnit[S: Type](given qctx: QuoteContext): Expr[Iso[S, 1]] = { import qctx.tasty.{_, given} import util._ @@ -160,7 +160,7 @@ object Iso { } // TODO: require whitebox macro - def implFields[S: TypeTag](given qctx: QuoteContext): Expr[Iso[S, Any]] = ??? + def implFields[S: Type](given qctx: QuoteContext): Expr[Iso[S, Any]] = ??? } object GenIso { @@ -195,7 +195,7 @@ object Prism { def apply(a: A): S = app(a) } - def impl[S: TypeTag, A <: S : TypeTag](given qctx: QuoteContext): Expr[Prism[S, A]] = { + def impl[S: Type, A <: S : Type](given qctx: QuoteContext): Expr[Prism[S, A]] = { import qctx.tasty.{_, given} import util._ diff --git a/tests/run-macros/i6679/Macro_1.scala b/tests/run-macros/i6679/Macro_1.scala index ebf218f83ec4..06a95ac798cd 100644 --- a/tests/run-macros/i6679/Macro_1.scala +++ b/tests/run-macros/i6679/Macro_1.scala @@ -1,6 +1,6 @@ import scala.quoted._ -def makeMatch[A: TypeTag](head : Expr[A])(given qctx : QuoteContext) : Expr[Unit] = { +def makeMatch[A: Type](head : Expr[A])(given qctx : QuoteContext) : Expr[Unit] = { import qctx.tasty.{_, given} val sacrifice = '{ $head match { case _ => ??? } } diff --git a/tests/run-macros/i7008/macro_1.scala b/tests/run-macros/i7008/macro_1.scala index a4f0e783e145..c2130cc60d6d 100644 --- a/tests/run-macros/i7008/macro_1.scala +++ b/tests/run-macros/i7008/macro_1.scala @@ -12,7 +12,7 @@ def mcrProxy(expr: Expr[Boolean])(given QuoteContext): Expr[Unit] = { res } -def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(given ctx: QuoteContext, tt: TypeTag[T]): Expr[Unit] = { +def mcrImpl[T](func: Expr[Seq[Box[T]] => Unit], expr: Expr[T])(given ctx: QuoteContext, tt: Type[T]): Expr[Unit] = { import ctx.tasty._ val arg = Expr.ofSeq(Seq('{(Box($expr))})) Expr.betaReduce(func)(arg) diff --git a/tests/run-macros/no-symbol/1.scala b/tests/run-macros/no-symbol/1.scala index 5c61b1e60299..fe7c219f7f80 100644 --- a/tests/run-macros/no-symbol/1.scala +++ b/tests/run-macros/no-symbol/1.scala @@ -5,10 +5,10 @@ case class Foo(i: Int) case class Box[A](x: A) object Macro { - inline def foo[T](implicit inline t: TypeTag[T]): String = + inline def foo[T](implicit inline t: Type[T]): String = ${ fooImpl } - def fooImpl[T](implicit t: TypeTag[T], qctx: QuoteContext): Expr[String] = { + 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" } diff --git a/tests/run-macros/quote-implicitMatch/Macro_1.scala b/tests/run-macros/quote-implicitMatch/Macro_1.scala index 8dca6744f4b7..1014571a5214 100644 --- a/tests/run-macros/quote-implicitMatch/Macro_1.scala +++ b/tests/run-macros/quote-implicitMatch/Macro_1.scala @@ -5,7 +5,7 @@ import scala.quoted.matching._ inline def f1[T]() = ${ f1Impl[T] } -def f1Impl[T: TypeTag](given QuoteContext) = { +def f1Impl[T: Type](given QuoteContext) = { searchImplicitExpr[Ordering[T]] match { case Some(ord) => '{ new TreeSet[T]()($ord) } case _ => '{ new HashSet[T] } diff --git a/tests/run-macros/quote-impure-by-name/quoted_1.scala b/tests/run-macros/quote-impure-by-name/quoted_1.scala index 14d287aad859..61a750f33b86 100644 --- a/tests/run-macros/quote-impure-by-name/quoted_1.scala +++ b/tests/run-macros/quote-impure-by-name/quoted_1.scala @@ -11,7 +11,7 @@ object Index { implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ${ succImpl[K, H, T]('prev) } - def succImpl[K: TypeTag, H: TypeTag, T: TypeTag](prev: Expr[Index[K, T]])(given QuoteContext): Expr[Index[K, (H, T)]] = { + def succImpl[K: Type, H: Type, T: Type](prev: Expr[Index[K, T]])(given QuoteContext): Expr[Index[K, (H, T)]] = { val value = s"1 + {${prev.show}}" '{new Index(${value})} } diff --git a/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala b/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala index 5bd502b1b705..4dbfccfce5c2 100644 --- a/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala +++ b/tests/run-macros/quote-indexed-map-by-name/quoted_1.scala @@ -7,10 +7,10 @@ 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](k: TypeTag[K], h: TypeTag[H], t: TypeTag[T])(given QuoteContext): Expr[Index[K, (H, T)]] = { - implicit val kk: TypeTag[K] = k - implicit val hh: TypeTag[H] = h - implicit val tt: TypeTag[T] = t + def succImpl[K, H, T](k: Type[K], h: Type[H], t: Type[T])(given QuoteContext): Expr[Index[K, (H, T)]] = { + implicit val kk: Type[K] = k + implicit val hh: Type[H] = h + implicit val tt: Type[T] = t '{new Index(0)} } } diff --git a/tests/run-macros/quote-matcher-runtime.check b/tests/run-macros/quote-matcher-runtime.check index 938408217ee6..6ff241b9fd61 100644 --- a/tests/run-macros/quote-matcher-runtime.check +++ b/tests/run-macros/quote-matcher-runtime.check @@ -719,14 +719,14 @@ Pattern: { @scala.internal.Quoted.patternBindHole type T scala.internal.Quoted.patternHole[scala.List[scala.Int]].foreach[T](scala.internal.Quoted.patternHole[scala.Function1[scala.Int, T]]) } -Result: Some(List(TypeTag(scala.Unit), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => scala.Predef.println(x))))) +Result: Some(List(Type(scala.Unit), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => scala.Predef.println(x))))) Scrutinee: scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int])).foreach[scala.Unit](((x: scala.Int) => scala.Predef.println(x))) Pattern: { @scala.internal.Quoted.patternBindHole type T = scala.Unit scala.internal.Quoted.patternHole[scala.List[scala.Int]].foreach[T](scala.internal.Quoted.patternHole[scala.Function1[scala.Int, T]]) } -Result: Some(List(TypeTag(scala.Unit), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => scala.Predef.println(x))))) +Result: Some(List(Type(scala.Unit), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => scala.Predef.println(x))))) Scrutinee: scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int])).foreach[scala.Unit](((x: scala.Int) => scala.Predef.println(x))) Pattern: { @@ -746,7 +746,7 @@ Pattern: { val b: T = scala.internal.Quoted.patternHole[T] () } -Result: Some(List(TypeTag(scala.Int), Expr(4), Expr(4))) +Result: Some(List(Type(scala.Int), Expr(4), Expr(4))) Scrutinee: { val a: scala.Int = 4 @@ -759,7 +759,7 @@ Pattern: { val b: T = scala.internal.Quoted.patternHole[T] () } -Result: Some(List(TypeTag(scala.Int), Expr(4), Expr(5))) +Result: Some(List(Type(scala.Int), Expr(4), Expr(5))) Scrutinee: { val a: scala.Int = 4 @@ -772,7 +772,7 @@ Pattern: { val b: T = scala.internal.Quoted.patternHole[T] () } -Result: Some(List(TypeTag(scala.Int | java.lang.String), Expr(4), Expr("x"))) +Result: Some(List(Type(scala.Int | java.lang.String), Expr(4), Expr("x"))) Scrutinee: { val a: scala.Int = 4 @@ -795,7 +795,7 @@ Pattern: { (scala.internal.Quoted.patternHole[scala.List[T]].map[U](scala.internal.Quoted.patternHole[scala.Function1[T, U]]).map[V](scala.internal.Quoted.patternHole[scala.Function1[U, V]]): scala.collection.immutable.List[scala.Any]) } -Result: Some(List(TypeTag(scala.Int), TypeTag(scala.Double), TypeTag(java.lang.String), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => x.toDouble./(2))), Expr(((y: scala.Double) => y.toString())))) +Result: Some(List(Type(scala.Int), Type(scala.Double), Type(java.lang.String), Expr(scala.List.apply[scala.Int]((1, 2, 3: scala.[scala.Int]))), Expr(((x: scala.Int) => x.toDouble./(2))), Expr(((y: scala.Double) => y.toString())))) Scrutinee: ((x: scala.Int) => x) Pattern: { @@ -803,7 +803,7 @@ Pattern: { (scala.internal.Quoted.patternHole[scala.Function1[T, T]]: scala.Function1[scala.Nothing, scala.Any]) } -Result: Some(List(TypeTag(scala.Int), Expr(((x: scala.Int) => x)))) +Result: Some(List(Type(scala.Int), Expr(((x: scala.Int) => x)))) Scrutinee: ((x: scala.Int) => x.toString()) Pattern: { @@ -819,7 +819,7 @@ Pattern: { (scala.internal.Quoted.patternHole[scala.Function1[T, T]]: scala.Function1[scala.Nothing, scala.Any]) } -Result: Some(List(TypeTag(scala.Nothing), Expr(((x: scala.Any) => scala.Predef.???)))) +Result: Some(List(Type(scala.Nothing), Expr(((x: scala.Any) => scala.Predef.???)))) Scrutinee: ((x: scala.Nothing) => (1: scala.Any)) Pattern: { diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 0bcbf43dd0e0..7087b7dc2a80 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -13,8 +13,8 @@ object Macros { tup.toArray.toList.map { case r: Expr[_] => s"Expr(${r.unseal.show})" - case r: TypeTag[_] => - s"TypeTag(${r.unseal.show})" + case r: quoted.Type[_] => + s"Type(${r.unseal.show})" case r: Sym[_] => s"Sym(${r.name})" } 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 1edeef40fd2a..ec5c1a948dc1 100644 --- a/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-1/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def lift[T](sym: Symantics[T])(a: => DSL): T = ${impl[T]('sym, 'a)} - private def impl[T: TypeTag](sym: Expr[Symantics[T]], a: Expr[DSL])(given qctx: QuoteContext): Expr[T] = { + private def impl[T: Type](sym: Expr[Symantics[T]], a: Expr[DSL])(given qctx: QuoteContext): Expr[T] = { def lift(e: Expr[DSL]): Expr[T] = e match { 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 f42f6e41d55b..6e80bdf92422 100644 --- a/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-2/quoted_1.scala @@ -9,7 +9,7 @@ object Macros { inline def liftAST(a: => DSL): ASTNum = ${impl(ASTNum, 'a)} - private def impl[T: TypeTag](sym: Symantics[T], a: Expr[DSL])(given qctx: QuoteContext): Expr[T] = { + private def impl[T: Type](sym: Symantics[T], a: Expr[DSL])(given qctx: QuoteContext): Expr[T] = { def lift(e: Expr[DSL])(implicit env: Map[Sym[DSL], Expr[T]]): Expr[T] = e match { diff --git a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala index 8196be051ef4..761398f7a632 100644 --- a/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala +++ b/tests/run-macros/quote-matcher-symantics-3/quoted_1.scala @@ -7,7 +7,7 @@ object Macros { inline def lift[R[_]](sym: Symantics { type Repr = R })(a: => Int): R[Int] = ${impl('sym, 'a)} - private def impl[R[_]: TypeTag](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int])(given QuoteContext): Expr[R[Int]] = { + private def impl[R[_]: Type](sym: Expr[Symantics { type Repr[X] = R[X] }], expr: Expr[Int])(given QuoteContext): Expr[R[Int]] = { type Env = Map[Any, Any] @@ -21,7 +21,7 @@ object Macros { summon[Env].get(id).asInstanceOf[Option[Expr[R[T]]]] // We can only add binds that have the same type as the refs } - def lift[T: TypeTag](e: Expr[T])(given env: Env): Expr[R[T]] = ((e: Expr[Any]) match { + def lift[T: Type](e: Expr[T])(given env: Env): Expr[R[T]] = ((e: Expr[Any]) match { case Const(e: Int) => '{ $sym.int(${Expr(e)}).asInstanceOf[R[T]] } case Const(e: Boolean) => '{ $sym.bool(${Expr(e)}).asInstanceOf[R[T]] } diff --git a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala index c31da76c688b..204e6c621cf4 100644 --- a/tests/run-macros/quote-matching-optimize-1/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-1/Macro_1.scala @@ -5,7 +5,7 @@ object Macro { inline def optimize[T](x: => T): Any = ${ Macro.impl('x) } - def impl[T: TypeTag](x: Expr[T])(given QuoteContext): Expr[Any] = { + def impl[T: Type](x: Expr[T])(given QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ type $t; ($ls: List[`$t`]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala index c756a2f38840..98dacda3df8d 100644 --- a/tests/run-macros/quote-matching-optimize-2/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-2/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def optimize[T](x: => T): Any = ${ Macro.impl('x) } - def impl[T: TypeTag](x: Expr[T])(given QuoteContext): Expr[Any] = { + def impl[T: Type](x: Expr[T])(given QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-matching-optimize-3/Macro_1.scala b/tests/run-macros/quote-matching-optimize-3/Macro_1.scala index 0397fe1465d9..0736dad4e1b7 100644 --- a/tests/run-macros/quote-matching-optimize-3/Macro_1.scala +++ b/tests/run-macros/quote-matching-optimize-3/Macro_1.scala @@ -7,7 +7,7 @@ object Macro { inline def optimize[T](x: => T): Any = ${ Macro.impl('x) } - def impl[T: TypeTag](x: Expr[T])(given QuoteContext): Expr[Any] = { + def impl[T: Type](x: Expr[T])(given QuoteContext): Expr[Any] = { def optimize(x: Expr[Any]): Expr[Any] = x match { case '{ ($ls: List[$t]).filter($f).filter($g) } => diff --git a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala index 09d7fd0f0914..58df1397e20e 100644 --- a/tests/run-macros/quote-toExprOfTuple/Macro_1.scala +++ b/tests/run-macros/quote-toExprOfTuple/Macro_1.scala @@ -3,7 +3,7 @@ import scala.quoted._ object Macro { inline def t2[T0, T1](t0: T0, t1: T1): (T0, T1) = ${ impl2('{t0}, '{t1}) } - def impl2[T0: TypeTag, T1: TypeTag](t0: Expr[T0], t1: Expr[T1])(given qctx: QuoteContext): Expr[(T0, T1)] = { + def impl2[T0: Type, T1: Type](t0: Expr[T0], t1: Expr[T1])(given qctx: QuoteContext): Expr[(T0, T1)] = { import qctx.tasty.{_, given} import util._ diff --git a/tests/run-macros/quote-type-matcher-2/quoted_1.scala b/tests/run-macros/quote-type-matcher-2/quoted_1.scala index f9ff8aa4857c..179d4fdaed65 100644 --- a/tests/run-macros/quote-type-matcher-2/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher-2/quoted_1.scala @@ -4,8 +4,8 @@ object Macros { inline def lift[A]: String = ${ matchesExpr('[A]) } - private def matchesExpr(tp: TypeTag[_])(given QuoteContext): Expr[String] = { - def lift(tp: TypeTag[_]): String = tp match { + private def matchesExpr(tp: Type[_])(given QuoteContext): Expr[String] = { + def lift(tp: Type[_]): String = tp match { case '[Int] => "%Int%" case '[List[$t]] => s"%List[${lift(t)}]%" case '[Option[$t]] => s"%Option[${lift(t)}]%" diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index 6198dc1e2119..e536120306cf 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -6,13 +6,13 @@ object Macros { inline def matches[A, B]: Unit = ${ matchesExpr('[A], '[B]) } - private def matchesExpr[A, B](a: TypeTag[A], b: TypeTag[B])(given qctx: QuoteContext): Expr[Unit] = { + private def matchesExpr[A, B](a: Type[A], b: Type[B])(given qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{Bind => _, _} - val res = scala.internal.quoted.TypeTag.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => + val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(b, true, qctx).map { tup => tup.toArray.toList.map { - case r: TypeTag[_] => - s"TypeTag(${r.unseal.show})" + case r: quoted.Type[_] => + s"Type(${r.unseal.show})" case r: Sym[_] => s"Sym(${r.name})" } diff --git a/tests/run-macros/quoted-pattern-type/Macro_1.scala b/tests/run-macros/quoted-pattern-type/Macro_1.scala index 785b703f536f..493eaf923437 100644 --- a/tests/run-macros/quoted-pattern-type/Macro_1.scala +++ b/tests/run-macros/quoted-pattern-type/Macro_1.scala @@ -4,7 +4,7 @@ object Lib { inline def foo[T](arg: => T): T = ${ impl('arg) } - private def impl[T: TypeTag](arg: Expr[T])(given QuoteContext): Expr[T] = { + private def impl[T: Type](arg: Expr[T])(given QuoteContext): Expr[T] = { arg match { case e @ '{ $x: Boolean } => '{ println("Boolean: " + $e); $e } case e @ '{ $x: Int } => '{ println("Int: " + $x); $x } diff --git a/tests/run-macros/reflect-isFunctionType/macro_1.scala b/tests/run-macros/reflect-isFunctionType/macro_1.scala index cb4d063216e2..bf2dcbde9492 100644 --- a/tests/run-macros/reflect-isFunctionType/macro_1.scala +++ b/tests/run-macros/reflect-isFunctionType/macro_1.scala @@ -1,32 +1,32 @@ import scala.quoted._ -inline def isFunctionType[T:TypeTag]: Boolean = ${ isFunctionTypeImpl('[T]) } +inline def isFunctionType[T:Type]: Boolean = ${ isFunctionTypeImpl('[T]) } -def isFunctionTypeImpl[T](tp: TypeTag[T])(given qctx: QuoteContext): Expr[Boolean] = { +def isFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isFunctionType) } -inline def isImplicitFunctionType[T:TypeTag]: Boolean = ${ isImplicitFunctionTypeImpl('[T]) } +inline def isImplicitFunctionType[T:Type]: Boolean = ${ isImplicitFunctionTypeImpl('[T]) } -def isImplicitFunctionTypeImpl[T](tp: TypeTag[T])(given qctx: QuoteContext): Expr[Boolean] = { +def isImplicitFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isImplicitFunctionType) } -inline def isErasedFunctionType[T:TypeTag]: Boolean = ${ isErasedFunctionTypeImpl('[T]) } +inline def isErasedFunctionType[T:Type]: Boolean = ${ isErasedFunctionTypeImpl('[T]) } -def isErasedFunctionTypeImpl[T](tp: TypeTag[T])(given qctx: QuoteContext): Expr[Boolean] = { +def isErasedFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isErasedFunctionType) } -inline def isDependentFunctionType[T:TypeTag]: Boolean = ${ isDependentFunctionTypeImpl('[T]) } +inline def isDependentFunctionType[T:Type]: Boolean = ${ isDependentFunctionTypeImpl('[T]) } -def isDependentFunctionTypeImpl[T](tp: TypeTag[T])(given qctx: QuoteContext): Expr[Boolean] = { +def isDependentFunctionTypeImpl[T](tp: Type[T])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} Expr(tp.unseal.tpe.isDependentFunctionType) } diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index d72f614e7804..86a6a05cf03f 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { inline def dealias[T]: String = ${ impl('[T]) } - def impl[T](x: TypeTag[T])(given qctx: QuoteContext): Expr[String] = { + def impl[T](x: quoted.Type[T])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty.{_, given} Expr(x.unseal.tpe.dealias.show) } diff --git a/tests/run-macros/tasty-extractors-types/quoted_1.scala b/tests/run-macros/tasty-extractors-types/quoted_1.scala index 905551ce3558..3b1f76337bea 100644 --- a/tests/run-macros/tasty-extractors-types/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-types/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { implicit inline def printType[T]: Unit = ${ impl('[T]) } - def impl[T](x: TypeTag[T])(given qctx: QuoteContext): Expr[Unit] = { + def impl[T](x: Type[T])(given qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given} val tree = x.unseal diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 2bd5660a0c3c..bae6fbf00040 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -25,7 +25,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: TypeTag[K], h: TypeTag[H], t: TypeTag[T]): Expr[Index[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.{_, given} def name(tp: TypeOrBounds): String = tp match { diff --git a/tests/run-macros/tasty-linenumber/quoted_1.scala b/tests/run-macros/tasty-linenumber/quoted_1.scala index e02ab07644c4..1645772f11f4 100644 --- a/tests/run-macros/tasty-linenumber/quoted_1.scala +++ b/tests/run-macros/tasty-linenumber/quoted_1.scala @@ -10,7 +10,7 @@ object LineNumber { implicit inline def line[T >: Unit <: Unit]: LineNumber = ${lineImpl('[T])} - def lineImpl(x: TypeTag[Unit])(given qctx: QuoteContext): Expr[LineNumber] = { + def lineImpl(x: Type[Unit])(given qctx: QuoteContext): Expr[LineNumber] = { import qctx.tasty.{_, given} '{new LineNumber(${rootPosition.startLine})} } diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index a205501f5b06..9b101ff66bb5 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -18,7 +18,7 @@ object Macros { } } - def impl2[T](x: TypeTag[T])(given qctx: QuoteContext): Expr[Unit] = { + def impl2[T](x: quoted.Type[T])(given qctx: QuoteContext): Expr[Unit] = { import qctx.tasty.{_, given} val pos = x.unseal.pos val code = x.unseal.show diff --git a/tests/run-macros/tasty-positioned/quoted_1.scala b/tests/run-macros/tasty-positioned/quoted_1.scala index e2cbb4a865f4..1d8442c0152b 100644 --- a/tests/run-macros/tasty-positioned/quoted_1.scala +++ b/tests/run-macros/tasty-positioned/quoted_1.scala @@ -10,7 +10,7 @@ object Positioned { implicit inline def apply[T](x: => T): Positioned[T] = ${impl('x)} - def impl[T](x: Expr[T])(implicit ev: TypeTag[T], qctx: QuoteContext): Expr[Positioned[T]] = { + def impl[T](x: Expr[T])(implicit ev: Type[T], qctx: QuoteContext): Expr[Positioned[T]] = { import qctx.tasty.{Position => _, _, given} val pos = rootPosition diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index 61a9f4a10ee9..c610dafc3944 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -5,7 +5,7 @@ object Macros { inline def simplified[T <: Tuple]: Seq[String] = ${ impl[T] } - def impl[T: TypeTag](given qctx: QuoteContext): Expr[Seq[String]] = { + def impl[T: Type](given qctx: QuoteContext): Expr[Seq[String]] = { import qctx.tasty.{_, given} def unpackTuple(tp: Type): List[Type] = { diff --git a/tests/run-macros/tasty-subtyping/quoted_1.scala b/tests/run-macros/tasty-subtyping/quoted_1.scala index c4df69bdeeed..5f3cdea1d42b 100644 --- a/tests/run-macros/tasty-subtyping/quoted_1.scala +++ b/tests/run-macros/tasty-subtyping/quoted_1.scala @@ -9,13 +9,13 @@ object Macros { inline def isSubTypeOf[T, U]: Boolean = ${isSubTypeOfImpl('[T], '[U])} - def isTypeEqualImpl[T, U](t: TypeTag[T], u: TypeTag[U])(given qctx: QuoteContext): Expr[Boolean] = { + def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(given qctx: QuoteContext): Expr[Boolean] = { import qctx.tasty.{_, given} val isTypeEqual = t.unseal.tpe =:= u.unseal.tpe isTypeEqual } - def isSubTypeOfImpl[T, U](t: TypeTag[T], u: TypeTag[U])(given qctx: QuoteContext): Expr[Boolean] = { + def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(given qctx: QuoteContext): Expr[Boolean] = { 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 4fc6c6258408..ba9126412170 100644 --- a/tests/run-macros/tasty-tree-map/quoted_1.scala +++ b/tests/run-macros/tasty-tree-map/quoted_1.scala @@ -4,7 +4,7 @@ object Macros { implicit inline def identityMaped[T](x: => T): T = ${ impl('x) } - def impl[T: TypeTag](x: Expr[T])(given qctx: QuoteContext): Expr[T] = { + def impl[T: Type](x: Expr[T])(given qctx: QuoteContext): Expr[T] = { import qctx.tasty.{_, given} val identityMap = new TreeMap { } val transformed = identityMap.transformTerm(x.unseal).seal.cast[T] diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index f872145f4b3a..3d4e77649f6b 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -2,7 +2,7 @@ import scala.quoted._ object TypeToolbox { inline def show[A]: String = ${ showImpl('[A]) } - private def showImpl[A, B](a: TypeTag[A])(given qctx: QuoteContext): Expr[String] = { + private def showImpl[A, B](a: Type[A])(given qctx: QuoteContext): Expr[String] = { import qctx.tasty.{_, given} Expr(a.show) } diff --git a/tests/run-staging/i3823-b.scala b/tests/run-staging/i3823-b.scala index c97dbec5db83..f4f77d3cabf5 100644 --- a/tests/run-staging/i3823-b.scala +++ b/tests/run-staging/i3823-b.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = withQuoteContext { - def f[T](x: Expr[T])(implicit t: TypeTag[T]) = '{ + def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val z: $t = $x } - println(f('{2})(TypeTag.IntTag).show) + println(f('{2})(Type.IntTag).show) } } diff --git a/tests/run-staging/i3823-c.scala b/tests/run-staging/i3823-c.scala index af75830fbded..5a6074788840 100644 --- a/tests/run-staging/i3823-c.scala +++ b/tests/run-staging/i3823-c.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = withQuoteContext { - def f[T](x: Expr[T])(implicit t: TypeTag[T]) = '{ + def f[T](x: Expr[T])(implicit t: Type[T]) = '{ val z = $x } - println(f('{2})(TypeTag.IntTag).show) + println(f('{2})(Type.IntTag).show) } } diff --git a/tests/run-staging/i3823.scala b/tests/run-staging/i3823.scala index fb5fc2f28512..c9702d3c1269 100644 --- a/tests/run-staging/i3823.scala +++ b/tests/run-staging/i3823.scala @@ -3,9 +3,9 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = withQuoteContext { - def f[T: TypeTag](x: Expr[T])(t: TypeTag[T]) = '{ + def f[T: Type](x: Expr[T])(t: Type[T]) = '{ val z: $t = $x } println(f('{2})('[Int]).show) } -} +} \ No newline at end of file diff --git a/tests/run-staging/i3847-b.scala b/tests/run-staging/i3847-b.scala index 06fba251680b..43d75b08949f 100644 --- a/tests/run-staging/i3847-b.scala +++ b/tests/run-staging/i3847-b.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ import scala.reflect.ClassTag object Arrays { - implicit def ArrayIsLiftable[T: Liftable](implicit t: TypeTag[T], qctx: QuoteContext): Liftable[Array[List[T]]] = { + implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], qctx: QuoteContext): Liftable[Array[List[T]]] = { new Liftable[Array[List[T]]] { def toExpr(arr: Array[List[T]]) = '{ new Array[List[$t]](${Expr(arr.length)}) diff --git a/tests/run-staging/i3847.scala b/tests/run-staging/i3847.scala index 11f85f438efc..2fe1d02d6690 100644 --- a/tests/run-staging/i3847.scala +++ b/tests/run-staging/i3847.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ import scala.reflect.ClassTag object Arrays { - implicit def ArrayIsLiftable[T: Liftable](implicit t: TypeTag[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { + implicit def ArrayIsLiftable[T: Liftable](implicit t: Type[T], ct: Expr[ClassTag[T]]): Liftable[Array[T]] = { new Liftable[Array[T]] { def toExpr(arr: Array[T]) = '{ new Array[$t](${Expr(arr.length)})($ct) diff --git a/tests/run-staging/i3947.scala b/tests/run-staging/i3947.scala index 554b02b965e6..4e65cdcfe2ae 100644 --- a/tests/run-staging/i3947.scala +++ b/tests/run-staging/i3947.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947b.scala b/tests/run-staging/i3947b.scala index de37a4ee8f74..68dcd0ea85da 100644 --- a/tests/run-staging/i3947b.scala +++ b/tests/run-staging/i3947b.scala @@ -7,7 +7,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println() diff --git a/tests/run-staging/i3947b2.scala b/tests/run-staging/i3947b2.scala index a06e34a8e487..6d4254a5e097 100644 --- a/tests/run-staging/i3947b2.scala +++ b/tests/run-staging/i3947b2.scala @@ -7,7 +7,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: (given QuoteContext) => java.lang.Class[T]) = { + def test[T: Type](clazz: (given QuoteContext) => java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println() diff --git a/tests/run-staging/i3947b3.scala b/tests/run-staging/i3947b3.scala index 4aa0148155c5..92a2e89e0628 100644 --- a/tests/run-staging/i3947b3.scala +++ b/tests/run-staging/i3947b3.scala @@ -7,7 +7,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947c.scala b/tests/run-staging/i3947c.scala index aeaac95c6dc5..f63890177c43 100644 --- a/tests/run-staging/i3947c.scala +++ b/tests/run-staging/i3947c.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947d.scala b/tests/run-staging/i3947d.scala index bee850ff02ea..3b44a5126b3f 100644 --- a/tests/run-staging/i3947d.scala +++ b/tests/run-staging/i3947d.scala @@ -5,7 +5,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947d2.scala b/tests/run-staging/i3947d2.scala index 6b03001ee497..cc9e2a3839de 100644 --- a/tests/run-staging/i3947d2.scala +++ b/tests/run-staging/i3947d2.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947e.scala b/tests/run-staging/i3947e.scala index 8d187456df0a..def71f6b51e9 100644 --- a/tests/run-staging/i3947e.scala +++ b/tests/run-staging/i3947e.scala @@ -7,7 +7,7 @@ object Test { def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947f.scala b/tests/run-staging/i3947f.scala index 3774e264e62a..048d6d296404 100644 --- a/tests/run-staging/i3947f.scala +++ b/tests/run-staging/i3947f.scala @@ -7,7 +7,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947g.scala b/tests/run-staging/i3947g.scala index 89d2bc2ad496..89d1d32c5c9a 100644 --- a/tests/run-staging/i3947g.scala +++ b/tests/run-staging/i3947g.scala @@ -5,7 +5,7 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947i.scala b/tests/run-staging/i3947i.scala index 961eb5fd2965..698b91b8b21b 100644 --- a/tests/run-staging/i3947i.scala +++ b/tests/run-staging/i3947i.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i3947j.scala b/tests/run-staging/i3947j.scala index 9eca12631093..ea6dae78d9a3 100644 --- a/tests/run-staging/i3947j.scala +++ b/tests/run-staging/i3947j.scala @@ -6,7 +6,7 @@ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def test[T: TypeTag](clazz: java.lang.Class[T]) = { + def test[T: Type](clazz: java.lang.Class[T]) = { val lclazz = Expr(clazz) val name = '{ ($lclazz).getCanonicalName } println(name.show) diff --git a/tests/run-staging/i4044b.scala b/tests/run-staging/i4044b.scala index 0d3e23c0b7d9..c1cb8058662c 100644 --- a/tests/run-staging/i4044b.scala +++ b/tests/run-staging/i4044b.scala @@ -7,7 +7,7 @@ sealed abstract class VarRef[T] { } object VarRef { - def apply[T: TypeTag, U: TypeTag](init: Expr[T])(body: VarRef[T] => Expr[U])(given QuoteContext): Expr[U] = '{ + def apply[T: Type, U: Type](init: Expr[T])(body: VarRef[T] => Expr[U])(given QuoteContext): Expr[U] = '{ var x = $init ${body( new VarRef { diff --git a/tests/run-staging/i4044e.scala b/tests/run-staging/i4044e.scala index 8426e579c6cb..331815e1b543 100644 --- a/tests/run-staging/i4044e.scala +++ b/tests/run-staging/i4044e.scala @@ -6,7 +6,7 @@ class Foo { def foo: Unit = withQuoteContext { val e: Expr[Int] = '{3} val f: Expr[Int] = '{5} - val t: TypeTag[Int] = '[Int] + val t: Type[Int] = '[Int] val q = '{ ${ '{ ($e + $f).asInstanceOf[$t] } } } println(q.show) } diff --git a/tests/run-staging/i4350.scala b/tests/run-staging/i4350.scala index 28d59a3c2b29..836f9845c6fd 100644 --- a/tests/run-staging/i4350.scala +++ b/tests/run-staging/i4350.scala @@ -2,7 +2,7 @@ import scala.quoted._ import scala.quoted.staging._ -class Foo[T: TypeTag] { +class Foo[T: Type] { def q(given QuoteContext) = '{(null: Any).asInstanceOf[T]} } diff --git a/tests/run-staging/i4591.scala b/tests/run-staging/i4591.scala index 8950718cca7b..58b14a1b6a2f 100644 --- a/tests/run-staging/i4591.scala +++ b/tests/run-staging/i4591.scala @@ -3,7 +3,7 @@ import scala.quoted.staging._ object Test { - def foo[T: TypeTag](init: Expr[T])(given QuoteContext): Expr[Unit] = '{ + def foo[T: Type](init: Expr[T])(given QuoteContext): Expr[Unit] = '{ var x = $init println(x) } diff --git a/tests/run-staging/i5247.scala b/tests/run-staging/i5247.scala index 1da1dc821c1a..684f0fa3f3c7 100644 --- a/tests/run-staging/i5247.scala +++ b/tests/run-staging/i5247.scala @@ -7,11 +7,11 @@ object Test { println(foo[Object].show) println(bar[Object].show) } - def foo[H : TypeTag](given QuoteContext): Expr[H] = { + def foo[H : Type](given QuoteContext): Expr[H] = { val t = '[H] '{ null.asInstanceOf[$t] } } - def bar[H : TypeTag](given QuoteContext): Expr[List[H]] = { + def bar[H : Type](given QuoteContext): Expr[List[H]] = { val t = '[List[H]] '{ null.asInstanceOf[$t] } } diff --git a/tests/run-staging/i5965.scala b/tests/run-staging/i5965.scala index 5e9c9939aee7..ae67c95ccff5 100644 --- a/tests/run-staging/i5965.scala +++ b/tests/run-staging/i5965.scala @@ -20,7 +20,7 @@ object Test { println(run(map)) } - def bound[T: TypeTag, S[_]: TypeTag](x: Expr[S[T]])(given QuoteContext): Expr[S[T]] = '{ + def bound[T: Type, S[_]: Type](x: Expr[S[T]])(given QuoteContext): Expr[S[T]] = '{ val y: S[T] = $x y } diff --git a/tests/run-staging/i5965b.scala b/tests/run-staging/i5965b.scala index 86259a7e8b61..cec76470478d 100644 --- a/tests/run-staging/i5965b.scala +++ b/tests/run-staging/i5965b.scala @@ -20,7 +20,7 @@ object Test { println(run(map)) } - def bound[T: TypeTag, S[_]: TypeTag](x: Expr[S[T]])(given QuoteContext): Expr[S[T]] = '{ + def bound[T: Type, S[_]: Type](x: Expr[S[T]])(given QuoteContext): Expr[S[T]] = '{ val y = $x y } diff --git a/tests/run-staging/i6263.scala b/tests/run-staging/i6263.scala index b586b909bfef..2c4706853daa 100644 --- a/tests/run-staging/i6263.scala +++ b/tests/run-staging/i6263.scala @@ -12,7 +12,7 @@ object Test { fn(1) } - def fn[T : TypeTag](v : T) = "ok" + def fn[T : Type](v : T) = "ok" } object O diff --git a/tests/run-staging/i6281.scala b/tests/run-staging/i6281.scala index c4e3abd90e1c..a20586881d6e 100644 --- a/tests/run-staging/i6281.scala +++ b/tests/run-staging/i6281.scala @@ -18,17 +18,17 @@ object Test extends App { } trait Effects[L <: HList] { - def reify[A](given TypeTag[A]): STM[A, L] => Expr[Stm[A, L]] - def reflect[A](given TypeTag[A]): Expr[Stm[A, L]] => STM[A, L] + def reify[A](given Type[A]): STM[A, L] => Expr[Stm[A, L]] + def reflect[A](given Type[A]): Expr[Stm[A, L]] => STM[A, L] } given empty : Effects[HNil] { - def reify[A](given TypeTag[A]) = m => m - def reflect[A](given TypeTag[A]) = m => m + def reify[A](given Type[A]) = m => m + def reflect[A](given Type[A]) = m => m } // for reify, we need type tags for E and also strangely for L. - implicit def cons [E, L <: HList](given Effects[L])(given TypeTag[E])(given TypeTag[L])(given QuoteContext): Effects[E :: L] = new Effects[E :: L] { - def reify[A](given TypeTag[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.betaReduce('k)(a))) } }} - def reflect[A](given TypeTag[A]) = m => k => Effects[L].reflect[E] { Expr.betaReduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} + implicit def cons [E, L <: HList](given Effects[L])(given Type[E])(given Type[L])(given QuoteContext): Effects[E :: L] = new Effects[E :: L] { + def reify[A](given Type[A]) = m => '{ k => ${ Effects[L].reify[E] { m( a => Effects[L].reflect[E](Expr.betaReduce('k)(a))) } }} + def reflect[A](given Type[A]) = m => k => Effects[L].reflect[E] { Expr.betaReduce(m)('{ a => ${ Effects[L].reify[E]( k('a)) } })} } def Effects[L <: HList](given Effects[L]): Effects[L] = summon[Effects[L]] diff --git a/tests/run-staging/quote-lib.scala b/tests/run-staging/quote-lib.scala index 77d6536d9af5..7fe391c50186 100644 --- a/tests/run-staging/quote-lib.scala +++ b/tests/run-staging/quote-lib.scala @@ -128,11 +128,11 @@ package liftable { } object Lets { - def letVal[T, U: TypeTag](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[U] = + def letVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T], qctx: QuoteContext): Expr[U] = '{ val letVal: $t = $expr; ${ body('letVal) } } - def letLazyVal[T, U: TypeTag](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[U] = + def letLazyVal[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T], qctx: QuoteContext): Expr[U] = '{ lazy val letLazyVal: $t = $expr; ${ body('letLazyVal) } } - def letDef[T, U: TypeTag](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[U] = + def letDef[T, U: Type](expr: Expr[T])(body: Expr[T] => Expr[U])(implicit t: Type[T], qctx: QuoteContext): Expr[U] = '{ def letDef: $t = $expr; ${ body('letDef) } } } @@ -144,15 +144,15 @@ package liftable { object Lists { - implicit class LiftedOps[T: Liftable](list: Expr[List[T]])(implicit t: TypeTag[T]) { - def foldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: TypeTag[U], qctx: QuoteContext): Expr[U] = + implicit class LiftedOps[T: Liftable](list: Expr[List[T]])(implicit t: Type[T]) { + def foldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U], qctx: QuoteContext): Expr[U] = '{ ($list).foldLeft[$u]($acc)($f) } def foreach(f: Expr[T => Unit])(given QuoteContext): Expr[Unit] = '{ ($list).foreach($f) } } - implicit class UnrolledOps[T: Liftable](list: List[T])(implicit t: TypeTag[T], qctx: QuoteContext) { - def unrolledFoldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: TypeTag[U]): Expr[U] = list match { + implicit class UnrolledOps[T: Liftable](list: List[T])(implicit t: Type[T], qctx: QuoteContext) { + def unrolledFoldLeft[U](acc: Expr[U])(f: Expr[(U, T) => U])(implicit u: Type[U]): Expr[U] = list match { case x :: xs => xs.unrolledFoldLeft('{ ($f).apply($acc, ${x}) })(f) case Nil => acc } diff --git a/tests/run-staging/quote-nested-4.check b/tests/run-staging/quote-nested-4.check index b8032db33a8e..29ac1bec619b 100644 --- a/tests/run-staging/quote-nested-4.check +++ b/tests/run-staging/quote-nested-4.check @@ -1,5 +1,5 @@ { - val t: scala.quoted.TypeTag[scala.Predef.String] = '[scala.Predef.String] + val t: scala.quoted.Type[scala.Predef.String] = '[scala.Predef.String] - (t: scala.quoted.TypeTag[scala.Predef.String]) + (t: scala.quoted.Type[scala.Predef.String]) } diff --git a/tests/run-staging/quote-owners-2.scala b/tests/run-staging/quote-owners-2.scala index 07d7464f8d91..0b0ce18b6697 100644 --- a/tests/run-staging/quote-owners-2.scala +++ b/tests/run-staging/quote-owners-2.scala @@ -5,12 +5,12 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - val q = f(g(TypeTag.IntTag)) + val q = f(g(Type.IntTag)) println(q.show) '{ println($q) } } - def f(t: TypeTag[List[Int]])(given QuoteContext): Expr[Int] = '{ + def f(t: Type[List[Int]])(given QuoteContext): Expr[Int] = '{ def ff: Int = { val a: $t = { type T = $t @@ -22,5 +22,5 @@ object Test { ff } - def g[T](a: TypeTag[T])(given QuoteContext): TypeTag[List[T]] = '[List[$a]] + def g[T](a: Type[T])(given QuoteContext): Type[List[T]] = '[List[$a]] } diff --git a/tests/run-staging/quote-type-tags.scala b/tests/run-staging/quote-type-tags.scala index 7a0c96241601..3b5cd3dedbe3 100644 --- a/tests/run-staging/quote-type-tags.scala +++ b/tests/run-staging/quote-type-tags.scala @@ -4,7 +4,7 @@ import scala.quoted.staging._ object Test { given Toolbox = Toolbox.make(getClass.getClassLoader) def main(args: Array[String]): Unit = run { - def asof[T: TypeTag, U](x: Expr[T], t: TypeTag[U]): Expr[U] = + def asof[T: Type, U](x: Expr[T], t: Type[U]): Expr[U] = '{$x.asInstanceOf[$t]} println(asof('{}, '[Unit]).show) diff --git a/tests/run-staging/quote-unrolled-foreach.scala b/tests/run-staging/quote-unrolled-foreach.scala index 42baa4b49c01..fbc4acb46645 100644 --- a/tests/run-staging/quote-unrolled-foreach.scala +++ b/tests/run-staging/quote-unrolled-foreach.scala @@ -54,7 +54,7 @@ object Test { } } - def foreach1Tpe1[T](arrRef: Expr[Array[T]], f: Expr[T => Unit])(implicit t: TypeTag[T], qctx: QuoteContext): Expr[Unit] = '{ + def foreach1Tpe1[T](arrRef: Expr[Array[T]], f: Expr[T => Unit])(implicit t: Type[T], qctx: QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { @@ -64,7 +64,7 @@ object Test { } } - def foreach1Tpe2[T: TypeTag](arrRef: Expr[Array[T]], f: Expr[T => Unit])(given QuoteContext): Expr[Unit] = '{ + def foreach1Tpe2[T: Type](arrRef: Expr[Array[T]], f: Expr[T => Unit])(given QuoteContext): Expr[Unit] = '{ val size = ($arrRef).length var i = 0 while (i < size) { diff --git a/tests/run-staging/quote-valueof-list.scala b/tests/run-staging/quote-valueof-list.scala index f1ed94088ae2..53efc0d69be1 100644 --- a/tests/run-staging/quote-valueof-list.scala +++ b/tests/run-staging/quote-valueof-list.scala @@ -24,7 +24,7 @@ object Test { } } - implicit def ValueOfExprList[T: ValueOfExpr: TypeTag]: ValueOfExpr[List[T]] = new { + implicit def ValueOfExprList[T: ValueOfExpr: Type]: ValueOfExpr[List[T]] = new { def apply(xs: Expr[List[T]])(given QuoteContext): Option[List[T]] = (xs: Expr[Any]) match { case '{ ($xs1: List[T]).::($x) } => for { head <- x.getValue; tail <- xs1.getValue } @@ -34,7 +34,7 @@ object Test { } } - implicit def ValueOfExprOption[T: ValueOfExpr: TypeTag]: ValueOfExpr[Option[T]] = new { + implicit def ValueOfExprOption[T: ValueOfExpr: Type]: ValueOfExpr[Option[T]] = new { def apply(expr: Expr[Option[T]])(given QuoteContext): Option[Option[T]] = expr match { case '{ Some[T]($x) } => for (v <- x.getValue) yield Some(v) case '{ None } => Some(None) diff --git a/tests/run-staging/shonan-hmm-simple.scala b/tests/run-staging/shonan-hmm-simple.scala index df844a5aa117..8a70a47f3a96 100644 --- a/tests/run-staging/shonan-hmm-simple.scala +++ b/tests/run-staging/shonan-hmm-simple.scala @@ -70,7 +70,7 @@ class RingPV[U: Liftable](u: Ring[U], eu: Ring[Expr[U]])(given QuoteContext) ext case class Complex[T](re: T, im: T) object Complex - implicit def isLiftable[T: TypeTag: Liftable]: Liftable[Complex[T]] = new Liftable[Complex[T]] { + implicit def isLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable[Complex[T]] { def toExpr(comp: Complex[T]) = '{Complex(${comp.re}, ${comp.im})} } @@ -96,7 +96,7 @@ class StaticVecOps[T] extends VecOps[Int, T] { } } -class ExprVecOps[T: TypeTag](given QuoteContext) extends VecOps[Expr[Int], Expr[T]] +class ExprVecOps[T: Type](given QuoteContext) extends VecOps[Expr[Int], Expr[T]] val reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = (plus, zero, vec) => '{ var sum = $zero var i = 0 diff --git a/tests/run-staging/shonan-hmm/Complex.scala b/tests/run-staging/shonan-hmm/Complex.scala index 805926acc634..1a884094bee7 100644 --- a/tests/run-staging/shonan-hmm/Complex.scala +++ b/tests/run-staging/shonan-hmm/Complex.scala @@ -4,7 +4,7 @@ import scala.quoted._ case class Complex[T](re: T, im: T) object Complex { - implicit def complexIsLiftable[T: TypeTag: Liftable]: Liftable[Complex[T]] = new Liftable { + implicit def complexIsLiftable[T: Type: Liftable]: Liftable[Complex[T]] = new Liftable { def toExpr(c: Complex[T]) = '{ Complex(${Expr(c.re)}, ${Expr(c.im)}) } } diff --git a/tests/run-staging/shonan-hmm/Lifters.scala b/tests/run-staging/shonan-hmm/Lifters.scala index 7b79af3adc57..478047331112 100644 --- a/tests/run-staging/shonan-hmm/Lifters.scala +++ b/tests/run-staging/shonan-hmm/Lifters.scala @@ -6,11 +6,11 @@ import scala.quoted._ import scala.quoted.autolift.given object Lifters { - implicit def LiftedClassTag[T: TypeTag: ClassTag] (given QuoteContext): Expr[ClassTag[T]] = { + implicit def LiftedClassTag[T: Type: ClassTag] (given QuoteContext): Expr[ClassTag[T]] = { '{ ClassTag(${summon[ClassTag[T]].runtimeClass })} } - implicit def ArrayIsLiftable[T : TypeTag: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = new Liftable[Array[T]] { + implicit def ArrayIsLiftable[T : Type: ClassTag](implicit l: Liftable[T]): Liftable[Array[T]] = new Liftable[Array[T]] { def toExpr(x: Array[T]) = '{ val array = new Array[T](${x.length})(${implicitly[Expr[ClassTag[T]]]}) ${initArray(x, 'array)} @@ -24,7 +24,7 @@ object Lifters { } } - private def initArray[T : Liftable : TypeTag](arr: Array[T], array: Expr[Array[T]])(given QuoteContext): Expr[Array[T]] = { + private def initArray[T : Liftable : Type](arr: Array[T], array: Expr[Array[T]])(given QuoteContext): Expr[Array[T]] = { UnrolledExpr.block( arr.zipWithIndex.map { case (x, i) => '{ $array(${i}) = ${x} } diff --git a/tests/run-staging/shonan-hmm/MVmult.scala b/tests/run-staging/shonan-hmm/MVmult.scala index 3bcd9ab97b1b..db529e952c08 100644 --- a/tests/run-staging/shonan-hmm/MVmult.scala +++ b/tests/run-staging/shonan-hmm/MVmult.scala @@ -99,7 +99,7 @@ object MVmult { } } - def initRows[T: TypeTag](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T])(given QuoteContext): Expr[T] = { + def initRows[T: Type](a: Array[Array[Int]])(cont: Array[Expr[Array[Int]]] => Expr[T])(given QuoteContext): Expr[T] = { import Lifters._ def loop(i: Int, acc: List[Expr[Array[Int]]]): Expr[T] = { if (i >= a.length) cont(acc.toArray.reverse) diff --git a/tests/run-staging/shonan-hmm/UnrolledExpr.scala b/tests/run-staging/shonan-hmm/UnrolledExpr.scala index 0e54d5c0352a..0ecb495322b0 100644 --- a/tests/run-staging/shonan-hmm/UnrolledExpr.scala +++ b/tests/run-staging/shonan-hmm/UnrolledExpr.scala @@ -8,7 +8,7 @@ object UnrolledExpr { } // TODO support blocks in the compiler to avoid creating trees of blocks? - def block[T: TypeTag](stats: Iterable[Expr[_]], expr: Expr[T])(given QuoteContext): Expr[T] = { + def block[T: Type](stats: Iterable[Expr[_]], expr: Expr[T])(given QuoteContext): Expr[T] = { def rec(stats: List[Expr[_]]): Expr[T] = stats match { case x :: xs => '{ $x; ${rec(xs)} } case Nil => expr diff --git a/tests/run-staging/shonan-hmm/VecROp.scala b/tests/run-staging/shonan-hmm/VecROp.scala index 7be9193584af..f03cc86ec09e 100644 --- a/tests/run-staging/shonan-hmm/VecROp.scala +++ b/tests/run-staging/shonan-hmm/VecROp.scala @@ -17,7 +17,7 @@ class StaticVecR[T](r: Ring[T]) extends VecSta with VecROp[Int, T, Unit] { override def toString(): String = s"StaticVecR($r)" } -class VecRDyn[T: TypeTag](given QuoteContext) extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit]] { +class VecRDyn[T: Type](given QuoteContext) extends VecDyn with VecROp[Expr[Int], Expr[T], Expr[Unit]] { def reduce: ((Expr[T], Expr[T]) => Expr[T], Expr[T], Vec[Expr[Int], Expr[T]]) => Expr[T] = { (plus, zero, vec) => '{ var sum = $zero @@ -32,7 +32,7 @@ class VecRDyn[T: TypeTag](given QuoteContext) extends VecDyn with VecROp[Expr[In override def toString(): String = s"VecRDyn" } -class VecRStaDim[T: TypeTag](r: Ring[T])(given QuoteContext) extends VecROp[Int, T, Expr[Unit]] { +class VecRStaDim[T: Type](r: Ring[T])(given QuoteContext) extends VecROp[Int, T, Expr[Unit]] { val M = new StaticVecR[T](r) def reduce: ((T, T) => T, T, Vec[Int, T]) => T = M.reduce val seq: (Expr[Unit], Expr[Unit]) => Expr[Unit] = (e1, e2) => '{ $e1; $e2 } @@ -46,7 +46,7 @@ class VecRStaDim[T: TypeTag](r: Ring[T])(given QuoteContext) extends VecROp[Int, override def toString(): String = s"VecRStaDim($r)" } -class VecRStaDyn[T : TypeTag : Liftable](r: Ring[PV[T]])(given QuoteContext) extends VecROp[PV[Int], PV[T], Expr[Unit]] { +class VecRStaDyn[T : Type : Liftable](r: Ring[PV[T]])(given QuoteContext) extends VecROp[PV[Int], PV[T], Expr[Unit]] { val VSta: VecROp[Int, PV[T], Expr[Unit]] = new VecRStaDim(r) val VDyn = new VecRDyn val dyn = Dyns.dyn[T] diff --git a/tests/run-staging/staged-streams_1.scala b/tests/run-staging/staged-streams_1.scala index 90127dcaca58..eb446aa8973a 100644 --- a/tests/run-staging/staged-streams_1.scala +++ b/tests/run-staging/staged-streams_1.scala @@ -72,7 +72,7 @@ object Test { case class Linear[A](producer: Producer[A]) extends StagedStream[A] case class Nested[A, B](producer: Producer[B], nestedf: B => StagedStream[A]) extends StagedStream[A] - case class Stream[A: TypeTag](stream: StagedStream[Expr[A]]) { + case class Stream[A: Type](stream: StagedStream[Expr[A]]) { /** Main consumer * @@ -83,7 +83,7 @@ object Test { * @tparam W the type of the accumulator * @return */ - def fold[W: TypeTag](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])): E[W] = { + def fold[W: Type](z: Expr[W], f: ((Expr[W], Expr[A]) => Expr[W])): E[W] = { Var(z) { s => '{ ${ foldRaw[Expr[A]]((a: Expr[A]) => s.update(f(s.get, a)), stream) } @@ -123,7 +123,7 @@ object Test { * @tparam B the element type of the returned stream * @return a new stream resulting from applying `mapRaw` and threading the element of the first stream downstream. */ - def map[B : TypeTag](f: (Expr[A] => Expr[B])): Stream[B] = { + def map[B : Type](f: (Expr[A] => Expr[B])): Stream[B] = { Stream(mapRaw[Expr[A], Expr[B]](a => k => k(f(a)), stream)) } @@ -171,7 +171,7 @@ object Test { } /** Flatmap */ - def flatMap[B : TypeTag](f: (Expr[A] => Stream[B])): Stream[B] = { + def flatMap[B : Type](f: (Expr[A] => Stream[B])): Stream[B] = { Stream(flatMapRaw[Expr[A], Expr[B]]((a => { val Stream (nested) = f(a); nested }), stream)) } @@ -305,7 +305,7 @@ object Test { * @tparam A the type of the producer's elements. * @return a linear or nested stream aware of the variable reference to decrement. */ - private def takeRaw[A: TypeTag](n: Expr[Int], stream: StagedStream[A])(given QuoteContext): StagedStream[A] = { + private def takeRaw[A: Type](n: Expr[Int], stream: StagedStream[A])(given QuoteContext): StagedStream[A] = { stream match { case linear: Linear[A] => { val enhancedProducer: Producer[(Var[Int], A)] = addCounter[A](n, linear.producer) @@ -336,7 +336,7 @@ object Test { /** A stream containing the first `n` elements of this stream. */ def take(n: Expr[Int])(given QuoteContext): Stream[A] = Stream(takeRaw[Expr[A]](n, stream)) - private def zipRaw[A: TypeTag, B: TypeTag](stream1: StagedStream[Expr[A]], stream2: StagedStream[B])(given QuoteContext): StagedStream[(Expr[A], B)] = { + private def zipRaw[A: Type, B: Type](stream1: StagedStream[Expr[A]], stream2: StagedStream[B])(given QuoteContext): StagedStream[(Expr[A], B)] = { (stream1, stream2) match { case (Linear(producer1), Linear(producer2)) => @@ -404,7 +404,7 @@ object Test { * @tparam A * @return */ - private def makeLinear[A: TypeTag](stream: StagedStream[Expr[A]])(given QuoteContext): Producer[Expr[A]] = { + private def makeLinear[A: Type](stream: StagedStream[Expr[A]])(given QuoteContext): Producer[Expr[A]] = { stream match { case Linear(producer) => producer case Nested(producer, nestedf) => { @@ -565,14 +565,14 @@ object Test { } /** zip **/ - def zip[B: TypeTag, C: TypeTag](f: (Expr[A] => Expr[B] => Expr[C]), stream2: Stream[B])(given QuoteContext): Stream[C] = { + def zip[B: Type, C: Type](f: (Expr[A] => Expr[B] => Expr[C]), stream2: Stream[B])(given QuoteContext): Stream[C] = { val Stream(stream_b) = stream2 Stream(mapRaw[(Expr[A], Expr[B]), Expr[C]]((t => k => k(f(t._1)(t._2))), zipRaw[A, Expr[B]](stream, stream_b))) } } object Stream { - def of[A: TypeTag](arr: Expr[Array[A]])(given QuoteContext): Stream[A] = { + def of[A: Type](arr: Expr[Array[A]])(given QuoteContext): Stream[A] = { val prod = new Producer[Expr[A]] { type St = (Var[Int], Var[Int], Expr[Array[A]]) diff --git a/tests/run-staging/staged-tuples/StagedTuple.scala b/tests/run-staging/staged-tuples/StagedTuple.scala index a6736d65c41d..7455af47ea5e 100644 --- a/tests/run-staging/staged-tuples/StagedTuple.scala +++ b/tests/run-staging/staged-tuples/StagedTuple.scala @@ -34,7 +34,7 @@ object StagedTuple { } } - def fromArrayStaged[T <: Tuple : TypeTag](xs: Expr[Array[Object]], size: Option[Int])(given QuoteContext): Expr[T] = { + def fromArrayStaged[T <: Tuple : Type](xs: Expr[Array[Object]], size: Option[Int])(given QuoteContext): Expr[T] = { if (!specialize) '{dynamicFromArray[T]($xs)} else xs.bind { xs => val tup: Expr[Any] = size match { @@ -68,7 +68,7 @@ object StagedTuple { } } - def sizeStaged[Res <: Int : TypeTag](tup: Expr[Tuple], size: Option[Int])(given QuoteContext): Expr[Res] = { + def sizeStaged[Res <: Int : Type](tup: Expr[Tuple], size: Option[Int])(given QuoteContext): Expr[Res] = { val res = if (!specialize) '{dynamicSize($tup)} else size match { @@ -78,7 +78,7 @@ object StagedTuple { res.as[Res] } - def headStaged[Tup <: NonEmptyTuple : TypeTag](tup: Expr[Tup], size: Option[Int])(given QuoteContext): Expr[Head[Tup]] = { + def headStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(given QuoteContext): Expr[Head[Tup]] = { if (!specialize) '{dynamicApply[Tup, 0]($tup, 0)} else { val resVal = size match { @@ -101,7 +101,7 @@ object StagedTuple { } } - def tailStaged[Tup <: NonEmptyTuple : TypeTag](tup: Expr[Tup], size: Option[Int])(given QuoteContext): Expr[Tail[Tup]] = { + def tailStaged[Tup <: NonEmptyTuple : Type](tup: Expr[Tup], size: Option[Int])(given QuoteContext): Expr[Tail[Tup]] = { if (!specialize) '{dynamicTail[Tup]($tup)} else { val res = size match { @@ -125,7 +125,7 @@ object StagedTuple { } } - def applyStaged[Tup <: NonEmptyTuple : TypeTag, N <: Int : TypeTag](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int])(given qctx: QuoteContext): Expr[Elem[Tup, N]] = { + def applyStaged[Tup <: NonEmptyTuple : Type, N <: Int : Type](tup: Expr[Tup], size: Option[Int], n: Expr[N], nValue: Option[Int])(given qctx: QuoteContext): Expr[Elem[Tup, N]] = { import reflect._ if (!specialize) '{dynamicApply($tup, $n)} @@ -185,7 +185,7 @@ object StagedTuple { } } - def consStaged[T <: Tuple & Singleton : TypeTag, H : TypeTag](self: Expr[T], x: Expr[H], tailSize: Option[Int])(given QuoteContext): Expr[H *: T] = + def consStaged[T <: Tuple & Singleton : Type, H : Type](self: Expr[T], x: Expr[H], tailSize: Option[Int])(given QuoteContext): Expr[H *: T] = if (!specialize) '{dynamicCons[H, T]($x, $self)} else { val res = tailSize match { @@ -207,7 +207,7 @@ object StagedTuple { res.as[H *: T] } - def concatStaged[Self <: Tuple & Singleton : TypeTag, That <: Tuple & Singleton : TypeTag](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int])(given QuoteContext): Expr[Concat[Self, That]] = { + def concatStaged[Self <: Tuple & Singleton : Type, That <: Tuple & Singleton : Type](self: Expr[Self], selfSize: Option[Int], that: Expr[That], thatSize: Option[Int])(given QuoteContext): Expr[Concat[Self, That]] = { if (!specialize) '{dynamicConcat[Self, That]($self, $that)} else { def genericConcat(xs: Expr[Tuple], ys: Expr[Tuple]): Expr[Tuple] = @@ -256,11 +256,11 @@ object StagedTuple { } } - private implicit class ExprOps[U: TypeTag](expr: Expr[U]) { + private implicit class ExprOps[U: Type](expr: Expr[U]) { - def as[T: TypeTag](given QuoteContext): Expr[T] = '{ $expr.asInstanceOf[T] } + def as[T: Type](given QuoteContext): Expr[T] = '{ $expr.asInstanceOf[T] } - def bind[T: TypeTag](in: Expr[U] => Expr[T])(given QuoteContext): Expr[T] = '{ + def bind[T: Type](in: Expr[U] => Expr[T])(given QuoteContext): Expr[T] = '{ val t: U = $expr ${in('t)} }