diff --git a/community-build/community-projects/PPrint b/community-build/community-projects/PPrint index ee55dc3d4e09..bb3f91fe9aa6 160000 --- a/community-build/community-projects/PPrint +++ b/community-build/community-projects/PPrint @@ -1 +1 @@ -Subproject commit ee55dc3d4e09f7de6db344e60ae8894d99a28493 +Subproject commit bb3f91fe9aa68450c873722a19d788081d930030 diff --git a/community-build/community-projects/munit b/community-build/community-projects/munit index 1c7f7725275a..1ac6990e3906 160000 --- a/community-build/community-projects/munit +++ b/community-build/community-projects/munit @@ -1 +1 @@ -Subproject commit 1c7f7725275ae0a7f2e112d9e6e44a8110bc8294 +Subproject commit 1ac6990e3906a5bc8cb927f50c864f530984f10c diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 6f0e0b28e403..a482f76918ed 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 6f0e0b28e4039fb7fd01508da246fad26423dcd9 +Subproject commit a482f76918ed15e5da3b47aac7475597bcdd7f90 diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index 0b1f1fea4983..b5d39b89ed7a 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit 0b1f1fea4983443a48b895f53837b9da30fce90d +Subproject commit b5d39b89ed7afd3203dd2639171d2cebd8207f7b diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index e9f14a2ce0e1..45181858a2e2 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit e9f14a2ce0e1212b486dac1372f966466d1270ed +Subproject commit 45181858a2e2518d7dd528ff300b4feb091f5444 diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala index 9875814ebaf2..e00194e840f1 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala @@ -1001,7 +1001,10 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern case _ => None end TypeTreeTypeTest - object TypeTree extends TypeTreeModule + object TypeTree extends TypeTreeModule: + def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeTree = + tp.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree + end TypeTree object TypeTreeMethodsImpl extends TypeTreeMethods: extension (self: TypeTree): @@ -1568,8 +1571,8 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern type TypeRepr = dotc.core.Types.Type object TypeRepr extends TypeReprModule: - def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): TypeRepr = - qtype.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree.tpe + def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeRepr = + tp.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree.tpe def typeConstructorOf(clazz: Class[?]): TypeRepr = if (clazz.isPrimitive) if (clazz == classOf[Boolean]) dotc.core.Symbols.defn.BooleanType @@ -2640,7 +2643,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern treeMatch(scrutinee.unseal(using this), pattern.unseal(using this)) def typeMatch(scrutinee: scala.quoted.Type[?], pattern: scala.quoted.Type[?]): Option[Tuple] = - treeMatch(scrutinee.unseal(using this), pattern.unseal(using this)) + treeMatch(reflect.TypeTree.of(using scrutinee), reflect.TypeTree.of(using pattern)) private def treeMatch(scrutinee: reflect.Tree, pattern: reflect.Tree): Option[Tuple] = { import reflect._ diff --git a/library/src-bootstrapped/scala/quoted/Expr.scala b/library/src-bootstrapped/scala/quoted/Expr.scala index 4b93adeefdb5..c545baffb253 100644 --- a/library/src-bootstrapped/scala/quoted/Expr.scala +++ b/library/src-bootstrapped/scala/quoted/Expr.scala @@ -25,7 +25,7 @@ abstract class Expr[+T] private[scala] { /** Checks is the `quoted.Expr[?]` is valid expression of type `X` */ def isExprOf[X](using tp: scala.quoted.Type[X])(using qctx: QuoteContext): Boolean = - this.unseal.tpe <:< tp.unseal.tpe + this.unseal.tpe <:< qctx.reflect.TypeRepr.of[X] /** Convert this to an `quoted.Expr[X]` if this expression is a valid expression of type `X` or throws */ def asExprOf[X](using tp: scala.quoted.Type[X])(using qctx: QuoteContext): scala.quoted.Expr[X] = { @@ -35,7 +35,7 @@ abstract class Expr[+T] private[scala] { throw Exception( s"""Expr cast exception: ${this.show} |of type: ${this.unseal.tpe.show} - |did not conform to type: ${tp.unseal.tpe.show} + |did not conform to type: ${qctx.reflect.TypeRepr.of[X].show} |""".stripMargin ) } @@ -189,7 +189,7 @@ object Expr { */ def summon[T](using tpe: Type[T])(using qctx: QuoteContext): Option[Expr[T]] = { import qctx.reflect._ - Implicits.search(tpe.unseal.tpe) match { + Implicits.search(TypeRepr.of[T]) match { case iss: ImplicitSearchSuccess => Some(iss.tree.seal.asInstanceOf[Expr[T]]) case isf: ImplicitSearchFailure => None } diff --git a/library/src-bootstrapped/scala/quoted/ExprMap.scala b/library/src-bootstrapped/scala/quoted/ExprMap.scala index 1a26c2d28841..962240187532 100644 --- a/library/src-bootstrapped/scala/quoted/ExprMap.scala +++ b/library/src-bootstrapped/scala/quoted/ExprMap.scala @@ -144,7 +144,7 @@ trait ExprMap: trees mapConserve (transformTypeCaseDef(_)) } - new MapChildren().transformTermChildren(e.unseal, tpe.unseal.tpe).asExprOf[T] + new MapChildren().transformTermChildren(e.unseal, TypeRepr.of[T]).asExprOf[T] } end ExprMap diff --git a/library/src-bootstrapped/scala/quoted/Type.scala b/library/src-bootstrapped/scala/quoted/Type.scala index 548c42ea9b3c..27f18821bd90 100644 --- a/library/src-bootstrapped/scala/quoted/Type.scala +++ b/library/src-bootstrapped/scala/quoted/Type.scala @@ -3,27 +3,24 @@ package scala.quoted import scala.annotation.compileTimeOnly /** Quoted type (or kind) `T` */ -abstract class Type[T <: AnyKind] private[scala] { - +abstract class Type[T <: AnyKind] private[scala]: /** The type represented `Type` */ type Underlying = T +end Type + +/** Some basic type tags, currently incomplete */ +object Type: /** Show a source code like representation of this type without syntax highlight */ - def show(using qctx: QuoteContext): String = this.unseal.show + def show[T](using tp: Type[T])(using qctx: QuoteContext): String = + qctx.reflect.TypeTree.of[T].show /** Shows the tree as fully typed source code colored with ANSI */ - def showAnsiColored(using qctx: QuoteContext): String = this.unseal.showAnsiColored - - /** View this expression `quoted.Type[T]` as a `TypeTree` */ - def unseal(using qctx: QuoteContext): qctx.reflect.TypeTree - -} - -/** Some basic type tags, currently incomplete */ -object Type { + def showAnsiColored[T](using tp: Type[T])(using qctx: QuoteContext): String = + qctx.reflect.TypeTree.of[T].showAnsiColored /** Return a quoted.Type with the given type */ @compileTimeOnly("Reference to `scala.quoted.Type.apply` was not handled by ReifyQuotes") given apply[T <: AnyKind] as (QuoteContext ?=> Type[T]) = ??? -} +end Type diff --git a/library/src-bootstrapped/scala/quoted/Varargs.scala b/library/src-bootstrapped/scala/quoted/Varargs.scala index 639ca807acb8..12be6b530aff 100644 --- a/library/src-bootstrapped/scala/quoted/Varargs.scala +++ b/library/src-bootstrapped/scala/quoted/Varargs.scala @@ -17,7 +17,7 @@ object Varargs { */ def apply[T](xs: Seq[Expr[T]])(using tp: Type[T], qctx: QuoteContext): Expr[Seq[T]] = { import qctx.reflect._ - Repeated(xs.map[Term](_.unseal).toList, tp.unseal).seal.asInstanceOf[Expr[Seq[T]]] + Repeated(xs.map[Term](_.unseal).toList, TypeTree.of[T]).seal.asInstanceOf[Expr[Seq[T]]] } /** Matches a literal sequence of expressions and return a sequence of expressions. diff --git a/library/src-non-bootstrapped/scala/quoted/Type.scala b/library/src-non-bootstrapped/scala/quoted/Type.scala index db15d9cb6a20..8aaad0aeff04 100644 --- a/library/src-non-bootstrapped/scala/quoted/Type.scala +++ b/library/src-non-bootstrapped/scala/quoted/Type.scala @@ -5,8 +5,6 @@ import scala.annotation.compileTimeOnly abstract class Type[T <: AnyKind] private[scala]: type Underlying = T - def unseal(using qctx: QuoteContext): qctx.reflect.TypeTree - object Type: @compileTimeOnly("Reference to `scala.quoted.Type.apply` was not handled by ReifyQuotes") given apply[T <: AnyKind] as (QuoteContext ?=> Type[T]) = ??? diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 2c1abf2b6c53..4956cbf9f0e3 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -1167,7 +1167,10 @@ trait Reflection { reflection => val TypeTree: TypeTreeModule - trait TypeTreeModule { this: TypeTree.type => } + trait TypeTreeModule { this: TypeTree.type => + /** Returns the tree of type or kind (TypeTree) of T */ + def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeTree + } given TypeTreeMethods as TypeTreeMethods = TypeTreeMethodsImpl protected val TypeTreeMethodsImpl: TypeTreeMethods @@ -1750,7 +1753,7 @@ trait Reflection { reflection => trait TypeReprModule { this: TypeRepr.type => /** Returns the type or kind (TypeRepr) of T */ - def of[T <: AnyKind](using qtype: scala.quoted.Type[T]): TypeRepr + def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeRepr /** Returns the type constructor of the runtime (erased) class */ def typeConstructorOf(clazz: Class[?]): TypeRepr diff --git a/tests/neg-macros/delegate-match-1/Macro_1.scala b/tests/neg-macros/delegate-match-1/Macro_1.scala index 267ad0851a26..782fe8b2f4e3 100644 --- a/tests/neg-macros/delegate-match-1/Macro_1.scala +++ b/tests/neg-macros/delegate-match-1/Macro_1.scala @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl } private def fImpl(using qctx: QuoteContext): Expr[Unit] = { import qctx.reflect._ - Implicits.search((Type[A]).unseal.tpe) match { + Implicits.search(TypeRepr.of[A]) match { case x: ImplicitSearchSuccess => '{} case x: DivergingImplicit => '{} diff --git a/tests/neg-macros/delegate-match-2/Macro_1.scala b/tests/neg-macros/delegate-match-2/Macro_1.scala index b8f1347cb136..e40f2f608e1d 100644 --- a/tests/neg-macros/delegate-match-2/Macro_1.scala +++ b/tests/neg-macros/delegate-match-2/Macro_1.scala @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl } private def fImpl (using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ - Implicits.search((Type[A]).unseal.tpe) match { + Implicits.search(TypeRepr.of[A]) match { case x: ImplicitSearchSuccess => '{} case x: DivergingImplicit => '{} diff --git a/tests/neg-macros/delegate-match-3/Macro_1.scala b/tests/neg-macros/delegate-match-3/Macro_1.scala index 2209dc26ee57..3167e3152d4f 100644 --- a/tests/neg-macros/delegate-match-3/Macro_1.scala +++ b/tests/neg-macros/delegate-match-3/Macro_1.scala @@ -5,7 +5,7 @@ inline def f: Any = ${ fImpl } private def fImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ - Implicits.search((Type[A]).unseal.tpe) match { + Implicits.search(TypeRepr.of[A]) match { case x: ImplicitSearchSuccess => '{} case x: DivergingImplicit => '{} diff --git a/tests/neg-macros/i7048e.scala b/tests/neg-macros/i7048e.scala index ffe4f843a4ed..7bce976792f8 100644 --- a/tests/neg-macros/i7048e.scala +++ b/tests/neg-macros/i7048e.scala @@ -14,7 +14,7 @@ abstract class Test { { val t: Test = this import t.given - println(summon[Type[t.T]].show) + println(Type.show[t.T]) // val r = '{Option.empty[t.T]} // access to value t from wrong staging level val r2 = '{Option.empty[t.T.Underlying]} // works } diff --git a/tests/neg-macros/i7919.scala b/tests/neg-macros/i7919.scala index 986f91a4fc29..49588f9c1f3e 100644 --- a/tests/neg-macros/i7919.scala +++ b/tests/neg-macros/i7919.scala @@ -4,7 +4,6 @@ object Test { def staged[T](using qctx: QuoteContext) = { import qctx.reflect._ given typeT as Type[T] // error - val tTypeTree = typeT.unseal val tt = TypeRepr.of[T] '{ "in staged" } } diff --git a/tests/pos-macros/i7048e.scala b/tests/pos-macros/i7048e.scala index ea27dd3ef141..64b81a812d53 100644 --- a/tests/pos-macros/i7048e.scala +++ b/tests/pos-macros/i7048e.scala @@ -14,7 +14,7 @@ abstract class Test { { val t: Test = this import t.given - println(summon[Type[t.T]].show) + println(Type.show[t.T]) // val r = '{Option.empty[t.T]} // access to value t from wrong staging level val r2 = '{Option.empty[t.T.Underlying]} } diff --git a/tests/pos-macros/i8521/Macro_1.scala b/tests/pos-macros/i8521/Macro_1.scala index 061029df42cf..716342dcd698 100644 --- a/tests/pos-macros/i8521/Macro_1.scala +++ b/tests/pos-macros/i8521/Macro_1.scala @@ -11,7 +11,7 @@ object Foo { packageToName(sym.owner) } - val sym = implicitly[Type[T]].unseal.symbol + val sym = TypeRepr.of[T].typeSymbol if (!sym.isNoSymbol) { sym.tree match { case c: ClassDef => diff --git a/tests/pos-macros/i9251/Macro_1.scala b/tests/pos-macros/i9251/Macro_1.scala index 304913be756d..d0c3264f0c97 100644 --- a/tests/pos-macros/i9251/Macro_1.scala +++ b/tests/pos-macros/i9251/Macro_1.scala @@ -26,9 +26,9 @@ object Async { case Inlined(_,_,Block(_,Apply(TypeApply(Select(q,n),tparams),List(param)))) => param.tpe match case AppliedType(tp,tparams1) => - val fType = Type[F] + val fType = TypeRepr.of[F] val ptp = tparams1.tail.head - val ptpTree = Inferred(fType.unseal.tpe.appliedTo(ptp)) + val ptpTree = Inferred(fType.appliedTo(ptp)) '{ println(${Expr(ptpTree.show)}) } } diff --git a/tests/pos-macros/i9518/Macro_1.scala b/tests/pos-macros/i9518/Macro_1.scala index d439c892bfe9..d5e734c9b744 100644 --- a/tests/pos-macros/i9518/Macro_1.scala +++ b/tests/pos-macros/i9518/Macro_1.scala @@ -8,11 +8,11 @@ inline def shift : Unit = ${ shiftTerm } def shiftTerm(using QuoteContext): Expr[Unit] = { import qctx.reflect._ val nTree = '{ ??? : CB[Int] }.unseal - val tp1 = Type[CB[Int]].unseal.tpe - val tp2 = Type[([X] =>> CB[X])[Int]].unseal.tpe + val tp1 = TypeRepr.of[CB[Int]] + val tp2 = TypeRepr.of[([X] =>> CB[X])[Int]] val ta = Type[[X] =>> CB[X]] - val tp3 = Type[ta.Underlying[Int]].unseal.tpe - val tp4 = Type[CB].unseal.tpe.appliedTo(TypeRepr.of[Int]) + val tp3 = TypeRepr.of(using Type[ta.Underlying[Int]]) + val tp4 = TypeRepr.of[CB].appliedTo(TypeRepr.of[Int]) assert(nTree.tpe <:< tp1) assert(nTree.tpe <:< tp2) assert(nTree.tpe <:< tp3) diff --git a/tests/pos-macros/i9894/Macro_1.scala b/tests/pos-macros/i9894/Macro_1.scala index 67e29d29fb69..3c0651b2abe2 100644 --- a/tests/pos-macros/i9894/Macro_1.scala +++ b/tests/pos-macros/i9894/Macro_1.scala @@ -45,7 +45,7 @@ object X: case lt@Lambda(params, body) => val paramTypes = params.map(_.tpt.tpe) val paramNames = params.map(_.name) - val mt = MethodType(paramNames)(_ => paramTypes, _ => Type[CB].unseal.tpe.appliedTo(body.tpe.widen) ) + val mt = MethodType(paramNames)(_ => paramTypes, _ => TypeRepr.of[CB].appliedTo(body.tpe.widen) ) val r = Lambda(mt, args => changeArgs(params,args,transform(body)) ) r case _ => diff --git a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala index 56d476e8019c..72114a3c9804 100644 --- a/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala +++ b/tests/run-custom-args/run-macros-erased/reflect-isFunctionType/macro_1.scala @@ -1,33 +1,33 @@ import scala.quoted._ -inline def isFunctionType[T]: Boolean = ${ isFunctionTypeImpl(Type[T]) } +inline def isFunctionType[T]: Boolean = ${ isFunctionTypeImpl[T] } -def isFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { +def isFunctionTypeImpl[T: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(tp.unseal.tpe.isFunctionType) + Expr(TypeRepr.of[T].isFunctionType) } -inline def isContextFunctionType[T]: Boolean = ${ isContextFunctionTypeImpl(Type[T]) } +inline def isContextFunctionType[T]: Boolean = ${ isContextFunctionTypeImpl[T] } -def isContextFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { +def isContextFunctionTypeImpl[T: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(tp.unseal.tpe.isContextFunctionType) + Expr(TypeRepr.of[T].isContextFunctionType) } -inline def isErasedFunctionType[T]: Boolean = ${ isErasedFunctionTypeImpl(Type[T]) } +inline def isErasedFunctionType[T]: Boolean = ${ isErasedFunctionTypeImpl[T] } -def isErasedFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { +def isErasedFunctionTypeImpl[T: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(tp.unseal.tpe.isErasedFunctionType) + Expr(TypeRepr.of[T].isErasedFunctionType) } -inline def isDependentFunctionType[T]: Boolean = ${ isDependentFunctionTypeImpl(Type[T]) } +inline def isDependentFunctionType[T]: Boolean = ${ isDependentFunctionTypeImpl[T] } -def isDependentFunctionTypeImpl[T](tp: Type[T])(using qctx: QuoteContext) : Expr[Boolean] = { +def isDependentFunctionTypeImpl[T: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(tp.unseal.tpe.isDependentFunctionType) + Expr(TypeRepr.of[T].isDependentFunctionType) } diff --git a/tests/run-macros/flops-rewrite-3/Macro_1.scala b/tests/run-macros/flops-rewrite-3/Macro_1.scala index 030284d63709..4df32b6f8684 100644 --- a/tests/run-macros/flops-rewrite-3/Macro_1.scala +++ b/tests/run-macros/flops-rewrite-3/Macro_1.scala @@ -59,7 +59,7 @@ class CheckedTransformation(transform: PartialFunction[Expr[Any], Expr[Any]]) ex def apply[T: Type](e: Expr[T])(using QuoteContext): Expr[T] = { transform.applyOrElse(e, identity) match { case '{ $e2: T } => e2 - case '{ $e2: $T } => + case '{ $e2: $T2 } => throw new Exception( s"""Transformed |${e.show} @@ -67,9 +67,9 @@ class CheckedTransformation(transform: PartialFunction[Expr[Any], Expr[Any]]) ex |${e2.show} | |Expected type to be - |${summon[Type[T]].show} + |${Type.show[T]} |but was - |${Type[T].show} + |${Type.show[T2]} """.stripMargin) } } diff --git a/tests/run-macros/flops-rewrite/Macro_1.scala b/tests/run-macros/flops-rewrite/Macro_1.scala index 24f8f4316bc4..e4d0f5a7f3a1 100644 --- a/tests/run-macros/flops-rewrite/Macro_1.scala +++ b/tests/run-macros/flops-rewrite/Macro_1.scala @@ -47,9 +47,9 @@ private class Rewriter(preTransform: Expr[Any] => Expr[Any], postTransform: Expr |${x.show} | |Expected type to be - |${summon[Type[T]].show} + |${Type.show[T]} |but was - |${Type[t].show} + |${Type.show[t]} """.stripMargin) } } 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 725dea7da052..51c619da310e 100644 --- a/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala @@ -5,98 +5,98 @@ import scala.quoted._ object TypeToolbox { /** are the two types equal? */ - inline def =:=[A, B]: Boolean = ${tpEqImpl(Type[A], Type[B])} - private def tpEqImpl[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Boolean] = { + inline def =:=[A, B]: Boolean = ${tpEqImpl[A, B]} + private def tpEqImpl[A: Type, B: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(a.unseal.tpe =:= b.unseal.tpe) + Expr(TypeRepr.of[A] =:= TypeRepr.of[B]) } /** is `tp1` a subtype of `tp2` */ - inline def <:<[A, B]: Boolean = ${tpLEqImpl(Type[A], Type[B])} - private def tpLEqImpl[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Boolean] = { + inline def <:<[A, B]: Boolean = ${tpLEqImpl[A, B]} + private def tpLEqImpl[A: Type, B: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(a.unseal.tpe <:< b.unseal.tpe) + Expr(TypeRepr.of[A] <:< TypeRepr.of[B]) } /** type associated with the tree */ - inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl('a, Type[Expected])} - private def typeOfImpl(a: Expr[_], expected: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { + inline def typeOf[T, Expected](a: T): Boolean = ${typeOfImpl[T, Expected]('a)} + private def typeOfImpl[A: Type, E: Type](a: Expr[A])(using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - Expr(a.unseal.tpe =:= expected.unseal.tpe) + Expr(TypeRepr.of[A] =:= TypeRepr.of[E]) } /** does the type refer to a case class? */ - inline def isCaseClass[A]: Boolean = ${isCaseClassImpl(Type[A])} - private def isCaseClassImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { + inline def isCaseClass[A]: Boolean = ${isCaseClassImpl[A]} + private def isCaseClassImpl[T: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - val sym = tp.unseal.symbol + val sym = TypeTree.of[T].symbol Expr(sym.isClassDef && sym.flags.is(Flags.Case)) } /** val fields of a case class Type -- only the ones declared in primary constructor */ - inline def caseFields[T]: List[String] = ${caseFieldsImpl(Type[T])} - private def caseFieldsImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[List[String]] = { + inline def caseFields[T]: List[String] = ${caseFieldsImpl[T]} + private def caseFieldsImpl[T: Type](using qctx: QuoteContext) : Expr[List[String]] = { import qctx.reflect._ - val fields = tp.unseal.symbol.caseFields.map(_.name) + val fields = TypeTree.of[T].symbol.caseFields.map(_.name) Expr(fields) } - inline def fieldIn[T](inline mem: String): String = ${fieldInImpl(Type[T], 'mem)} - private def fieldInImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[String] = { + inline def fieldIn[T](inline mem: String): String = ${fieldInImpl[T]('mem)} + private def fieldInImpl[T: Type](mem: Expr[String])(using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ - val field = t.unseal.symbol.field(mem.unliftOrError) + val field = TypeTree.of[T].symbol.field(mem.unliftOrError) Expr(if field.isNoSymbol then "" else field.name) } - inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl(Type[T])} - private def fieldsInImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { + inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl[T]} + private def fieldsInImpl[T: Type](using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - val fields = t.unseal.symbol.fields + val fields = TypeTree.of[T].symbol.fields Expr(fields.map(_.name).toList) } - inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl(Type[T], 'mem)} - private def methodInImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { + inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl[T]('mem)} + private def methodInImpl[T: Type](mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - Expr(t.unseal.symbol.classMethod(mem.unliftOrError).map(_.name)) + Expr(TypeTree.of[T].symbol.classMethod(mem.unliftOrError).map(_.name)) } - inline def methodsIn[T]: Seq[String] = ${methodsInImpl(Type[T])} - private def methodsInImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { + inline def methodsIn[T]: Seq[String] = ${methodsInImpl[T]} + private def methodsInImpl[T: Type](using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - Expr(t.unseal.symbol.classMethods.map(_.name)) + Expr(TypeTree.of[T].symbol.classMethods.map(_.name)) } - inline def method[T](inline mem: String): Seq[String] = ${methodImpl(Type[T], 'mem)} - private def methodImpl(t: Type[_], mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { + inline def method[T](inline mem: String): Seq[String] = ${methodImpl[T]('mem)} + private def methodImpl[T: Type](mem: Expr[String])(using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - Expr(t.unseal.symbol.method(mem.unliftOrError).map(_.name)) + Expr(TypeTree.of[T].symbol.method(mem.unliftOrError).map(_.name)) } - inline def methods[T]: Seq[String] = ${methodsImpl(Type[T])} - private def methodsImpl(t: Type[_])(using qctx: QuoteContext) : Expr[Seq[String]] = { + inline def methods[T]: Seq[String] = ${methodsImpl[T]} + private def methodsImpl[T: Type](using qctx: QuoteContext) : Expr[Seq[String]] = { import qctx.reflect._ - Expr(t.unseal.symbol.methods.map(_.name)) + Expr(TypeTree.of[T].symbol.methods.map(_.name)) } - inline def typeTag[T](x: T): String = ${typeTagImpl(Type[T])} - private def typeTagImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[String] = { + inline def typeTag[T](x: T): String = ${typeTagImpl[T]} + private def typeTagImpl[T: Type](using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ - val res = tp.unseal.tpe.show + val res = TypeRepr.of[T].show Expr(res) } - inline def companion[T1, T2]: Boolean = ${companionImpl(Type[T1], Type[T2])} - private def companionImpl(t1: Type[_], t2: Type[_])(using qctx: QuoteContext) : Expr[Boolean] = { + inline def companion[T1, T2]: Boolean = ${companionImpl[T1, T2]} + private def companionImpl[T1: Type, T2: Type](using qctx: QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - val res = t1.unseal.symbol.companionModule == t2.unseal.symbol + val res = TypeTree.of[T1].symbol.companionModule == TypeTree.of[T2].symbol Expr(res) } - inline def companionName[T1]: String = ${companionNameImpl(Type[T1])} - private def companionNameImpl(tp: Type[_])(using qctx: QuoteContext) : Expr[String] = { + inline def companionName[T1]: String = ${companionNameImpl[T1]} + private def companionNameImpl[T: Type](using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ - val sym = tp.unseal.symbol + val sym = TypeTree.of[T].symbol val companionClass = if sym.isClassDef then sym.companionModule.companionClass else if sym.isValDef then sym.companionClass diff --git a/tests/run-macros/i7987/Macros_1.scala b/tests/run-macros/i7987/Macros_1.scala index a68cfbd90f1a..7e69475de45e 100644 --- a/tests/run-macros/i7987/Macros_1.scala +++ b/tests/run-macros/i7987/Macros_1.scala @@ -7,6 +7,6 @@ object Macros { def macroImpl[T]()(using qctx: QuoteContext): Expr[String] = { Expr.summon[Mirror.Of[Some[Int]]] match - case Some('{ $_ : $T }) => Expr(Type[T].show) + case Some('{ $_ : $T }) => Expr(Type.show[T]) } } diff --git a/tests/run-macros/i8007/Macro_1.scala b/tests/run-macros/i8007/Macro_1.scala index 74c932b55b5b..ba6f9b4018ad 100644 --- a/tests/run-macros/i8007/Macro_1.scala +++ b/tests/run-macros/i8007/Macro_1.scala @@ -6,7 +6,7 @@ object Macro1 { def mirrorFields[T: Type](using qctx: QuoteContext): List[String] = Type[T] match { - case '[$Field *: $Fields] => Type[Field].show :: mirrorFields[Fields] + case '[$Field *: $Fields] => Type.show[Field] :: mirrorFields[Fields] case '[EmptyTuple] => Nil } diff --git a/tests/run-macros/i8007/Macro_2.scala b/tests/run-macros/i8007/Macro_2.scala index 1d3c82a55d84..31b8a107f13c 100644 --- a/tests/run-macros/i8007/Macro_2.scala +++ b/tests/run-macros/i8007/Macro_2.scala @@ -6,7 +6,7 @@ object Macro2 { def mirrorFields[T](using t: Type[T])(using qctx: QuoteContext): List[String] = t match { - case '[$Field *: $Fields] => Type[Field].show.substring(1, Type[Field].show.length-1) :: mirrorFields[Fields] + case '[$Field *: $Fields] => Type.show[Field].substring(1, Type.show[Field].length-1) :: mirrorFields[Fields] case '[EmptyTuple] => Nil } diff --git a/tests/run-macros/i8514/Macro_1.scala b/tests/run-macros/i8514/Macro_1.scala index f3aa6e71133a..44257052ae69 100644 --- a/tests/run-macros/i8514/Macro_1.scala +++ b/tests/run-macros/i8514/Macro_1.scala @@ -10,9 +10,9 @@ def testExpr(using QuoteContext): Expr[Unit] = { import qctx.reflect._ '{ - println(${Expr(Type[Object].unseal.tpe.baseClasses.toString)}) - println(${Expr(Type[A].unseal.tpe.baseClasses.toString)}) - println(${Expr(Type[B].unseal.tpe.baseClasses.toString)}) - println(${Expr(Type[C].unseal.tpe.baseClasses.toString)}) + println(${Expr(TypeRepr.of[Object].baseClasses.toString)}) + println(${Expr(TypeRepr.of[A].baseClasses.toString)}) + println(${Expr(TypeRepr.of[B].baseClasses.toString)}) + println(${Expr(TypeRepr.of[C].baseClasses.toString)}) } } diff --git a/tests/run-macros/i8514b/Macro_1.scala b/tests/run-macros/i8514b/Macro_1.scala index 9bef0f3cac09..75540acc556d 100644 --- a/tests/run-macros/i8514b/Macro_1.scala +++ b/tests/run-macros/i8514b/Macro_1.scala @@ -9,7 +9,7 @@ inline def test(): Unit = ${ testExpr } def testExpr(using QuoteContext): Expr[Unit] = { import qctx.reflect._ - val t = Type[B].unseal.tpe + val t = TypeRepr.of[B] val baseTypes = t.baseClasses.map(b => t.baseType(b)) '{ diff --git a/tests/run-macros/i8520/Macro_1.scala b/tests/run-macros/i8520/Macro_1.scala index 2fe47f7fe8a3..74100f7b7560 100644 --- a/tests/run-macros/i8520/Macro_1.scala +++ b/tests/run-macros/i8520/Macro_1.scala @@ -8,6 +8,6 @@ def testExpr[T[_]: Type](using QuoteContext): Expr[Unit] = { if f.is(Flags.Covariant) then "+" else if f.is(Flags.Contravariant) then "-" else " " - val t = Type[T].unseal.tpe.typeSymbol.typeMembers.map(x => (x.name, variance(x.flags))) + val t = TypeRepr.of[T].typeSymbol.typeMembers.map(x => (x.name, variance(x.flags))) '{ println(${Expr(t.toString)}) } } diff --git a/tests/run-macros/i9206/Macros_1.scala b/tests/run-macros/i9206/Macros_1.scala index 9d512f46c02f..21f35e641d0c 100644 --- a/tests/run-macros/i9206/Macros_1.scala +++ b/tests/run-macros/i9206/Macros_1.scala @@ -1,11 +1,12 @@ -import scala.quoted.{Expr, QuoteContext} +import scala.quoted._ object Inspect { inline def inspect[T <: AnyKind]: String = ${ inspectTpe[T] } - def inspectTpe[T <: AnyKind](using tpe: quoted.Type[T], qctx0: QuoteContext): Expr[String] = { - val tree = summon[quoted.Type[T]].unseal.tpe.typeSymbol.tree + def inspectTpe[T <: AnyKind: Type](using QuoteContext): Expr[String] = { + import qctx.reflect.TypeRepr + val tree = TypeRepr.of[T].typeSymbol.tree Expr(tree.show) } } diff --git a/tests/run-macros/no-symbol/1.scala b/tests/run-macros/no-symbol/1.scala index 982a4c648f8b..931938df3cb3 100644 --- a/tests/run-macros/no-symbol/1.scala +++ b/tests/run-macros/no-symbol/1.scala @@ -10,7 +10,7 @@ object Macro { def fooImpl[T](implicit t: Type[T], qctx: QuoteContext): Expr[String] = { import qctx.reflect._ - val sym = t.unseal.symbol + val sym = TypeTree.of[T].symbol if sym.isClassDef then '{ "symbol" } else if sym.isNoSymbol then '{ "no symbol" } else '{ "match error" } diff --git a/tests/run-macros/quote-matcher-runtime/quoted_1.scala b/tests/run-macros/quote-matcher-runtime/quoted_1.scala index 6bad6afb3547..e9280998a8a5 100644 --- a/tests/run-macros/quote-matcher-runtime/quoted_1.scala +++ b/tests/run-macros/quote-matcher-runtime/quoted_1.scala @@ -10,9 +10,9 @@ object Macros { val res = scala.internal.quoted.Expr.unapply[Tuple, Tuple](a)(using b, qctx).map { tup => tup.toArray.toList.map { case r: Expr[_] => - s"Expr(${r.unseal.show})" - case r: Type[_] => - s"Type(${r.unseal.show})" + s"Expr(${r.show})" + case t: Type[_] => + s"Type(${Type.show(using t)})" } } 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 a5544333af02..c034ffc19c70 100644 --- a/tests/run-macros/quote-type-matcher-2/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher-2/quoted_1.scala @@ -10,7 +10,7 @@ object Macros { case '[List[$T]] => s"%List[${lift[T]}]%" case '[Option[$T]] => s"%Option[${lift[T]}]%" case '[Function1[$T, $U]] => s"%${lift[T]} => ${lift[U]}%" - case _ => tp.show + case _ => Type.show[T] } Expr(lift[A]) } diff --git a/tests/run-macros/quote-type-matcher/quoted_1.scala b/tests/run-macros/quote-type-matcher/quoted_1.scala index b29ea1212d80..20dce5ab98f4 100644 --- a/tests/run-macros/quote-type-matcher/quoted_1.scala +++ b/tests/run-macros/quote-type-matcher/quoted_1.scala @@ -2,23 +2,21 @@ import scala.quoted._ object Macros { - inline def matches[A, B]: Unit = ${ matchesExpr(Type[A], Type[B]) } + inline def matches[A, B]: Unit = ${ matchesExpr[A, B] } - private def matchesExpr[A, B](a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Unit] = { + private def matchesExpr[A, B](using a: Type[A], b: Type[B])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ val res = scala.internal.quoted.Type.unapply[Tuple, Tuple](a)(using b, qctx).map { tup => tup.toArray.toList.map { case r: Type[_] => - s"Type(${r.unseal.show})" - case r: String => - s"String($r)" + s"Type(${TypeTree.of(using r).show})" } } '{ - println("Scrutinee: " + ${Expr(a.unseal.show)}) - println("Pattern: " + ${Expr(b.unseal.show)}) + println("Scrutinee: " + ${Expr(TypeTree.of[A].show)}) + println("Pattern: " + ${Expr(TypeTree.of[B].show)}) println("Result: " + ${Expr(res.toString)}) println() } diff --git a/tests/run-macros/refined-selectable-macro/Macro_1.scala b/tests/run-macros/refined-selectable-macro/Macro_1.scala index 864944e34a81..3dbc1020b16e 100644 --- a/tests/run-macros/refined-selectable-macro/Macro_1.scala +++ b/tests/run-macros/refined-selectable-macro/Macro_1.scala @@ -89,7 +89,7 @@ object Macro { val r = rec(repr, Set.empty) - val refinementType = r.foldLeft(Type[T].unseal.tpe)((acc, e) => Refinement(acc, e._1, e._2)).seal + val refinementType = r.foldLeft(TypeRepr.of[T])((acc, e) => Refinement(acc, e._1, e._2)).seal refinementType match { case '[$T] => '{ $newRecord($s.toArray.map(e => e.asInstanceOf[(String, Any)])).asInstanceOf[T] } diff --git a/tests/run-macros/string-context-implicits/Macro_1.scala b/tests/run-macros/string-context-implicits/Macro_1.scala index c439444d8451..f17d99bd0a57 100644 --- a/tests/run-macros/string-context-implicits/Macro_1.scala +++ b/tests/run-macros/string-context-implicits/Macro_1.scala @@ -11,7 +11,7 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using val showTp = Type[Show[Tp]] Expr.summon(using showTp) match { case Some(showExpr) => '{ $showExpr.show($arg) } - case None => report.error(s"could not find implicit for ${showTp.show}", arg); '{???} + case None => report.error(s"could not find implicit for ${Type.show[Show[Tp]]}", arg); '{???} } } val newArgsExpr = Varargs(argShowedExprs) diff --git a/tests/run-macros/tasty-construct-types/Macro_1.scala b/tests/run-macros/tasty-construct-types/Macro_1.scala index 2be63040e607..7adc1d0429a0 100644 --- a/tests/run-macros/tasty-construct-types/Macro_1.scala +++ b/tests/run-macros/tasty-construct-types/Macro_1.scala @@ -40,14 +40,14 @@ object Macros { tl => TypeRepr.of[scala.internal.MatchCase].appliedTo(List(TypeRepr.of[List].appliedTo(tl.param(0)), tl.param(0))))) ) - assert(x1T =:= Type[1].unseal.tpe) - assert(x2T =:= Type[1|2].unseal.tpe) - assert(x3T =:= Type[3&Any].unseal.tpe) - assert(x4T =:= Type[[A,B] =>> B].unseal.tpe) - assert(x5T =:= Type[RefineMe { type T = Int }].unseal.tpe) - assert(x6T =:= Type[List[Int]].unseal.tpe) - assert(x7T =:= Type[7 @TestAnnotation].unseal.tpe) - assert(x8T =:= Type[List[8] match { case List[t] => t }].unseal.tpe) + assert(x1T =:= TypeRepr.of[1]) + assert(x2T =:= TypeRepr.of(using Type[1|2])) + assert(x3T =:= TypeRepr.of[3&Any]) + assert(x4T =:= TypeRepr.of[[A,B] =>> B]) + assert(x5T =:= TypeRepr.of[RefineMe { type T = Int }]) + assert(x6T =:= TypeRepr.of[List[Int]]) + assert(x7T =:= TypeRepr.of[7 @TestAnnotation]) + assert(x8T =:= TypeRepr.of[List[8] match { case List[t] => t }]) '{ println("Ok") diff --git a/tests/run-macros/tasty-dealias/quoted_1.scala b/tests/run-macros/tasty-dealias/quoted_1.scala index f6885c410d91..b57137d439e4 100644 --- a/tests/run-macros/tasty-dealias/quoted_1.scala +++ b/tests/run-macros/tasty-dealias/quoted_1.scala @@ -2,10 +2,10 @@ import scala.quoted._ object Macros { - inline def dealias[T]: String = ${ impl(Type[T]) } + inline def dealias[T]: String = ${ impl[T] } - def impl[T](x: Type[T])(using qctx: QuoteContext) : Expr[String] = { + def impl[T: Type](using qctx: QuoteContext) : Expr[String] = { import qctx.reflect._ - Expr(x.unseal.tpe.dealias.show) + Expr(TypeRepr.of[T].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 97afb977d4f1..eba636d98416 100644 --- a/tests/run-macros/tasty-extractors-types/quoted_1.scala +++ b/tests/run-macros/tasty-extractors-types/quoted_1.scala @@ -2,15 +2,13 @@ import scala.quoted._ object Macros { - implicit inline def printType[T]: Unit = ${ impl(Type[T]) } + implicit inline def printType[T]: Unit = ${ impl[T] } - def impl[T](x: Type[T])(using qctx: QuoteContext) : Expr[Unit] = { + def impl[T: Type](using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ - - val tree = x.unseal '{ - println(${Expr(tree.showExtractors)}) - println(${Expr(tree.tpe.showExtractors)}) + println(${Expr(TypeTree.of[T].showExtractors)}) + println(${Expr(TypeRepr.of[T].showExtractors)}) println() } } diff --git a/tests/run-macros/tasty-indexed-map/quoted_1.scala b/tests/run-macros/tasty-indexed-map/quoted_1.scala index 902d58a439b8..af49b7fc10ff 100644 --- a/tests/run-macros/tasty-indexed-map/quoted_1.scala +++ b/tests/run-macros/tasty-indexed-map/quoted_1.scala @@ -36,8 +36,8 @@ object Index { case _ => Nil } - val key = name(k.unseal.tpe) - val keys = name(h.unseal.tpe) :: names(t.unseal.tpe) + val key = name(TypeRepr.of[K]) + val keys = name(TypeRepr.of[H]) :: names(TypeRepr.of[T]) val index = keys.indexOf(key) diff --git a/tests/run-macros/tasty-macro-positions/quoted_1.scala b/tests/run-macros/tasty-macro-positions/quoted_1.scala index c10fde0d5e64..449bcae3b8a5 100644 --- a/tests/run-macros/tasty-macro-positions/quoted_1.scala +++ b/tests/run-macros/tasty-macro-positions/quoted_1.scala @@ -6,7 +6,7 @@ object Macros { inline def fun2(x: =>Any): Unit = ${ impl('x) } - inline def fun3[T]: Unit = ${ impl2(Type[T]) } + inline def fun3[T]: Unit = ${ impl2(using Type[T]) } def impl(x: Expr[Any])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ @@ -18,10 +18,10 @@ object Macros { } } - def impl2[T](x: Type[T])(using qctx: QuoteContext) : Expr[Unit] = { + def impl2[T](using x: Type[T])(using qctx: QuoteContext) : Expr[Unit] = { import qctx.reflect._ - val pos = x.unseal.pos - val code = x.unseal.show + val pos = TypeTree.of[T].pos + val code = TypeTree.of[T].show '{ println(${posStr(qctx)(pos)}) println(${Expr(code)}) diff --git a/tests/run-macros/tasty-subtyping/quoted_1.scala b/tests/run-macros/tasty-subtyping/quoted_1.scala index 9be8b1ac52d9..bfbb9fd74892 100644 --- a/tests/run-macros/tasty-subtyping/quoted_1.scala +++ b/tests/run-macros/tasty-subtyping/quoted_1.scala @@ -3,20 +3,20 @@ import scala.quoted._ object Macros { inline def isTypeEqual[T, U]: Boolean = - ${isTypeEqualImpl(Type[T], Type[U])} + ${isTypeEqualImpl[T, U]} inline def isSubTypeOf[T, U]: Boolean = - ${isSubTypeOfImpl(Type[T], Type[U])} + ${isSubTypeOfImpl[T, U]} - def isTypeEqualImpl[T, U](t: Type[T], u: Type[U])(using QuoteContext) : Expr[Boolean] = { + def isTypeEqualImpl[T: Type, U: Type](using QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - val isTypeEqual = t.unseal.tpe =:= u.unseal.tpe + val isTypeEqual = TypeRepr.of[T] =:= TypeRepr.of[U] Expr(isTypeEqual) } - def isSubTypeOfImpl[T, U](t: Type[T], u: Type[U])(using QuoteContext) : Expr[Boolean] = { + def isSubTypeOfImpl[T: Type, U: Type](using QuoteContext) : Expr[Boolean] = { import qctx.reflect._ - val isTypeEqual = t.unseal.tpe <:< u.unseal.tpe + val isTypeEqual = TypeRepr.of[T] <:< TypeRepr.of[U] Expr(isTypeEqual) } } diff --git a/tests/run-macros/type-show/Macro_1.scala b/tests/run-macros/type-show/Macro_1.scala index 1d15b28b514a..4be7ec722dfd 100644 --- a/tests/run-macros/type-show/Macro_1.scala +++ b/tests/run-macros/type-show/Macro_1.scala @@ -1,9 +1,7 @@ import scala.quoted._ object TypeToolbox { - inline def show[A]: String = ${ showImpl(Type[A]) } - private def showImpl[A, B](a: Type[A])(using qctx: QuoteContext) : Expr[String] = { - import qctx.reflect._ - Expr(a.show) - } + inline def show[A]: String = ${ showImpl[A] } + private def showImpl[A: Type](using qctx: QuoteContext) : Expr[String] = + Expr(Type.show[A]) } diff --git a/tests/run-staging/quote-type-matcher.scala b/tests/run-staging/quote-type-matcher.scala index a9e69734a3ef..e6cef1a23767 100644 --- a/tests/run-staging/quote-type-matcher.scala +++ b/tests/run-staging/quote-type-matcher.scala @@ -9,20 +9,20 @@ object Test { Type[List[Int]] match case '[List[$Int]] => - println(Type[Int].show) + println(Type.show[Int]) println() Type[Int => Double] match case '[Function1[$T1, $R]] => - println(Type[T1].show) - println(Type[R].show) + println(Type.show[T1]) + println(Type.show[R]) println() Type[(Int => Short) => Double] match case '[Function1[Function1[$T1, $R0], $R]] => - println(Type[T1].show) - println(Type[R0].show) - println(Type[R].show) + println(Type.show[T1]) + println(Type.show[R0]) + println(Type.show[R]) } }