From b32ae8f7cfb8e5bbb3b0aa757519f1db7512bdf4 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 7 Sep 2020 15:34:45 +0200 Subject: [PATCH] Homogenize Reflect Type constructors * Rename Reflect.typeOf to Reflect.Type.of * Rename Reflect.Type.apply to Reflect.Type.ofClass * Make Reflect.Type.of AnyKinded * Improve some other type uses in community build --- .../community-projects/dotty-cps-async | 2 +- community-build/community-projects/scalatest | 2 +- community-build/community-projects/shapeless | 2 +- community-build/community-projects/utest | 2 +- .../community-projects/xml-interpolator | 2 +- .../reflect/ReflectionCompilerInterface.scala | 6 ++-- .../dotty/internal/StringContextMacro.scala | 14 ++++---- .../scala/quoted/Liftable.scala | 2 +- .../scala/quoted/util/ExprMap.scala | 2 +- .../internal/tasty/CompilerInterface.scala | 2 +- library/src/scala/tasty/Reflection.scala | 24 ++++++------- library/src/scala/tasty/reflect/Types.scala | 2 +- tests/neg-macros/i7919.scala | 2 +- tests/neg-macros/i8871.scala | 2 +- tests/neg-macros/i8871b.scala | 2 +- tests/pos-macros/i8879/Macro_1.scala | 2 +- tests/pos-macros/i9240/Macro_1.scala | 2 +- tests/pos-macros/i9518/Macro_1.scala | 2 +- tests/run-macros/i5941/macro_1.scala | 6 ++-- tests/run-macros/i6518/Macro_1.scala | 2 +- .../tasty-construct-types/Macro_1.scala | 18 +++++----- .../tasty-create-method-symbol/Macro_1.scala | 32 ++++++++--------- .../tasty-simplified/quoted_1.scala | 2 +- tests/run-macros/tasty-typeof/Macro_1.scala | 34 +++++++++---------- 24 files changed, 82 insertions(+), 86 deletions(-) diff --git a/community-build/community-projects/dotty-cps-async b/community-build/community-projects/dotty-cps-async index ae2276432b15..82c352728dbc 160000 --- a/community-build/community-projects/dotty-cps-async +++ b/community-build/community-projects/dotty-cps-async @@ -1 +1 @@ -Subproject commit ae2276432b158e1b42fb1941d79cd864dde78194 +Subproject commit 82c352728dbcd66884c2cb02cfd7c69670eb794e diff --git a/community-build/community-projects/scalatest b/community-build/community-projects/scalatest index 0bd4fc55e35f..44fc9482f777 160000 --- a/community-build/community-projects/scalatest +++ b/community-build/community-projects/scalatest @@ -1 +1 @@ -Subproject commit 0bd4fc55e35f923f4c94516d4eb53729e9ed0365 +Subproject commit 44fc9482f7772c2a327406b2768c95383abf23ce diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index dcabf2858fb0..ce4820deda2f 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit dcabf2858fb08e0af0d59d4f1833c8f396125f50 +Subproject commit ce4820deda2f3a9bc7f5c2f7d3cfa7d42307a4a3 diff --git a/community-build/community-projects/utest b/community-build/community-projects/utest index 8dcbfae35157..338899d51a7a 160000 --- a/community-build/community-projects/utest +++ b/community-build/community-projects/utest @@ -1 +1 @@ -Subproject commit 8dcbfae351578a86663c93f7ca186ff3d3323af0 +Subproject commit 338899d51a7a530fdadb7b91f4b19148c0e496cc diff --git a/community-build/community-projects/xml-interpolator b/community-build/community-projects/xml-interpolator index 4cf44bc97ce9..884549e858b8 160000 --- a/community-build/community-projects/xml-interpolator +++ b/community-build/community-projects/xml-interpolator @@ -1 +1 @@ -Subproject commit 4cf44bc97ce9ca9a4f6735f600ff96fd50b28ac9 +Subproject commit 884549e858b8e6ba4ab51031994aa0a71a7bdc90 diff --git a/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala index 8ca193a7538b..84eb79f08b6a 100644 --- a/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala @@ -1128,7 +1128,7 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte case _ => None } - def Type_apply(clazz: Class[?])(using Context): Type = + def Type_ofClass(clazz: Class[?])(using Context): Type = if (clazz.isPrimitive) if (clazz == classOf[Boolean]) defn.BooleanType else if (clazz == classOf[Byte]) defn.ByteType @@ -1140,10 +1140,10 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte else if (clazz == classOf[Double]) defn.DoubleType else defn.UnitType else if (clazz.isArray) - defn.ArrayType.appliedTo(Type_apply(clazz.getComponentType)) + defn.ArrayType.appliedTo(Type_ofClass(clazz.getComponentType)) else if (clazz.isMemberClass) { val name = clazz.getSimpleName.toTypeName - val enclosing = Type_apply(clazz.getEnclosingClass) + val enclosing = Type_ofClass(clazz.getEnclosingClass) if (enclosing.member(name).exists) enclosing.select(name) else enclosing.classSymbol.companionModule.termRef.select(name) diff --git a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala index 84dcbf96c837..cfccec84a1ba 100644 --- a/library/src-bootstrapped/dotty/internal/StringContextMacro.scala +++ b/library/src-bootstrapped/dotty/internal/StringContextMacro.scala @@ -586,9 +586,9 @@ object StringContextMacro { */ def checkTypeWithArgs(argument : (Type, Int), conversionChar : Char, partIndex : Int, flags : List[(Char, Int)]) = { val booleans = List(defn.BooleanType, defn.NullType) - val dates = List(defn.LongType, typeOf[java.util.Calendar], typeOf[java.util.Date]) - val floatingPoints = List(defn.DoubleType, defn.FloatType, typeOf[java.math.BigDecimal]) - val integral = List(defn.IntType, defn.LongType, defn.ShortType, defn.ByteType, typeOf[java.math.BigInteger]) + val dates = List(defn.LongType, Type.ofClass[java.util.Calendar], Type.ofClass[java.util.Date]) + val floatingPoints = List(defn.DoubleType, defn.FloatType, Type.ofClass[java.math.BigDecimal]) + val integral = List(defn.IntType, defn.LongType, defn.ShortType, defn.ByteType, Type.ofClass[java.math.BigInteger]) val character = List(defn.CharType, defn.ByteType, defn.ShortType, defn.IntType) val (argType, argIndex) = argument @@ -597,9 +597,9 @@ object StringContextMacro { case 'd' | 'o' | 'x' | 'X' => { checkSubtype(argType, "Int", argIndex, integral : _*) if (conversionChar != 'd') { - val notAllowedFlagOnCondition = List(('+', !(argType <:< typeOf[java.math.BigInteger]), "only use '+' for BigInt conversions to o, x, X"), - (' ', !(argType <:< typeOf[java.math.BigInteger]), "only use ' ' for BigInt conversions to o, x, X"), - ('(', !(argType <:< typeOf[java.math.BigInteger]), "only use '(' for BigInt conversions to o, x, X"), + val notAllowedFlagOnCondition = List(('+', !(argType <:< Type.ofClass[java.math.BigInteger]), "only use '+' for BigInt conversions to o, x, X"), + (' ', !(argType <:< Type.ofClass[java.math.BigInteger]), "only use ' ' for BigInt conversions to o, x, X"), + ('(', !(argType <:< Type.ofClass[java.math.BigInteger]), "only use '(' for BigInt conversions to o, x, X"), (',', true, "',' only allowed for d conversion of integral types")) checkFlags(partIndex, flags, notAllowedFlagOnCondition : _*) } @@ -608,7 +608,7 @@ object StringContextMacro { case 't' | 'T' => checkSubtype(argType, "Date", argIndex, dates : _*) case 'b' | 'B' => checkSubtype(argType, "Boolean", argIndex, booleans : _*) case 'h' | 'H' | 'S' | 's' => - if (!(argType <:< typeOf[java.util.Formattable])) + if (!(argType <:< Type.ofClass[java.util.Formattable])) for {flag <- flags ; if (flag._1 == '#')} reporter.argError("type mismatch;\n found : " + argType.widen.show.stripPrefix("scala.Predef.").stripPrefix("java.lang.").stripPrefix("scala.") + "\n required: java.util.Formattable", argIndex) case 'n' | '%' => diff --git a/library/src-bootstrapped/scala/quoted/Liftable.scala b/library/src-bootstrapped/scala/quoted/Liftable.scala index 3744c8302477..68f8b2499390 100644 --- a/library/src-bootstrapped/scala/quoted/Liftable.scala +++ b/library/src-bootstrapped/scala/quoted/Liftable.scala @@ -60,7 +60,7 @@ object Liftable { given ClassLiftable[T] as Liftable[Class[T]] = new Liftable[Class[T]] { def toExpr(x: Class[T]) = qctx ?=> { import qctx.tasty._ - Ref(defn.Predef_classOf).appliedToType(Type(x)).seal.asInstanceOf[Expr[Class[T]]] + Ref(defn.Predef_classOf).appliedToType(Type.ofClass(using ClassTag(x))).seal.asInstanceOf[Expr[Class[T]]] } } diff --git a/library/src-bootstrapped/scala/quoted/util/ExprMap.scala b/library/src-bootstrapped/scala/quoted/util/ExprMap.scala index 6864c45fbe39..428f3538808b 100644 --- a/library/src-bootstrapped/scala/quoted/util/ExprMap.scala +++ b/library/src-bootstrapped/scala/quoted/util/ExprMap.scala @@ -63,7 +63,7 @@ trait ExprMap { case Typed(expr, tpt) => val tp = tpt.tpe match case AppliedType(TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), ""), List(tp0: Type)) => - Type(classOf[Seq[_]]).appliedTo(tp0) + Type.ofClass[Seq[_]].appliedTo(tp0) case tp => tp Typed.copy(tree)(transformTerm(expr, tp), transformTypeTree(tpt)) case tree: NamedArg => diff --git a/library/src/scala/internal/tasty/CompilerInterface.scala b/library/src/scala/internal/tasty/CompilerInterface.scala index 080e059900ff..0abe6eda1a9c 100644 --- a/library/src/scala/internal/tasty/CompilerInterface.scala +++ b/library/src/scala/internal/tasty/CompilerInterface.scala @@ -512,7 +512,7 @@ trait CompilerInterface extends scala.tasty.reflect.Types { def Type_TypeTest(using ctx: Context): TypeTest[Type, Type] - def Type_apply(clazz: Class[_])(using ctx: Context): Type + def Type_ofClass(clazz: Class[_])(using ctx: Context): Type /** Is `self` type the same as `that` type? * This is the case iff `Type_isSubType(self, that)` and `Type_isSubType(that, self)`. diff --git a/library/src/scala/tasty/Reflection.scala b/library/src/scala/tasty/Reflection.scala index 135a89d75f3a..b770bdb550ec 100644 --- a/library/src/scala/tasty/Reflection.scala +++ b/library/src/scala/tasty/Reflection.scala @@ -1336,11 +1336,6 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface => // TYPES // /////////////// - /** Returns the type (Type) of T */ - def typeOf[T](using qtype: scala.quoted.Type[T], ctx: Context): Type = - qtype.asInstanceOf[scala.internal.quoted.Type[T]].typeTree.asInstanceOf[TypeTree].tpe - - // ----- Types ---------------------------------------------------- given (using ctx: Context) as TypeTest[Type, Type] = reflectSelf.Type_TypeTest @@ -1348,8 +1343,13 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface => object Type: - def apply(clazz: Class[_])(using ctx: Context): Type = - reflectSelf.Type_apply(clazz) + /** Returns the type or kind (Type) of T */ + def of[T <: AnyKind](using qtype: scala.quoted.Type[T], ctx: Context): Type = + qtype.asInstanceOf[scala.internal.quoted.Type[TypeTree]].typeTree.tpe + + /** Returns the type or kind of the class of the type T */ + def ofClass[T](using ct: scala.reflect.ClassTag[T]): Type = + reflectSelf.Type_ofClass(ct.runtimeClass) extension (self: Type): @@ -1626,13 +1626,9 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface => end MatchType - /** - * An accessor for `scala.internal.MatchCase[_,_]`, the representation of a `MatchType` case. - */ - def MatchCaseType(using ctx: Context): Type = { - import scala.internal.MatchCase - Type(classOf[MatchCase[_,_]]) - } + /** An accessor for `scala.internal.MatchCase[_,_]`, the representation of a `MatchType` case. */ + def MatchCaseType(using ctx: Context): Type = + Type.ofClass[scala.internal.MatchCase[_,_]] given (using ctx: Context) as TypeTest[Type, ByNameType] = reflectSelf.ByNameType_TypeTest given ByNameTypeOps as ByNameType.type = ByNameType diff --git a/library/src/scala/tasty/reflect/Types.scala b/library/src/scala/tasty/reflect/Types.scala index 0f1b234dbd44..95aa8e1c3b44 100644 --- a/library/src/scala/tasty/reflect/Types.scala +++ b/library/src/scala/tasty/reflect/Types.scala @@ -292,7 +292,7 @@ trait Types { /** Pattern representing `X | Y | ...` alternatives. */ type Alternatives <: Tree - /** A type */ + /** A type, kind, type bounds or NoPrefix */ type Type /** A singleton type representing a known constant value */ diff --git a/tests/neg-macros/i7919.scala b/tests/neg-macros/i7919.scala index dff211eb562d..fcb0c240ee9c 100644 --- a/tests/neg-macros/i7919.scala +++ b/tests/neg-macros/i7919.scala @@ -5,7 +5,7 @@ object Test { import qctx.tasty._ given typeT as quoted.Type[T] // error val tTypeTree = typeT.unseal - val tt = typeOf[T] + val tt = Type.of[T] '{ "in staged" } } diff --git a/tests/neg-macros/i8871.scala b/tests/neg-macros/i8871.scala index 4fa1bd3af936..d217d30b1d15 100644 --- a/tests/neg-macros/i8871.scala +++ b/tests/neg-macros/i8871.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { def impl[A : Type](using qctx: QuoteContext): Unit = { import qctx.tasty._ - val tpe = typeOf[A].seal.asInstanceOf[quoted.Type[_ <: AnyRef]] + val tpe = Type.of[A].seal.asInstanceOf[quoted.Type[_ <: AnyRef]] '{ (a: ${tpe}) => ???} // error } } diff --git a/tests/neg-macros/i8871b.scala b/tests/neg-macros/i8871b.scala index bb363e90f29e..a837e0d20a6e 100644 --- a/tests/neg-macros/i8871b.scala +++ b/tests/neg-macros/i8871b.scala @@ -2,7 +2,7 @@ import scala.quoted._ object Macro { def impl[A : Type](using qctx: QuoteContext): Unit = { import qctx.tasty._ - val tpe/*: quoted.Type[? <: AnyKind]*/ = typeOf[A].seal + val tpe/*: quoted.Type[? <: AnyKind]*/ = Type.of[A].seal '{ f[$tpe] } // error } def f[T <: AnyKind]: Unit = () diff --git a/tests/pos-macros/i8879/Macro_1.scala b/tests/pos-macros/i8879/Macro_1.scala index fda2363167b0..806464642e1f 100644 --- a/tests/pos-macros/i8879/Macro_1.scala +++ b/tests/pos-macros/i8879/Macro_1.scala @@ -9,7 +9,7 @@ object Test { import qctx.tasty._ import util._ - val foo = typeOf[Foo[String]] + val foo = Type.of[Foo[String]] val symbol = foo.typeSymbol.field("a") val a = foo.select(symbol) assert(a <:< defn.StringType) diff --git a/tests/pos-macros/i9240/Macro_1.scala b/tests/pos-macros/i9240/Macro_1.scala index 7f85002816ff..15a4f106173e 100644 --- a/tests/pos-macros/i9240/Macro_1.scala +++ b/tests/pos-macros/i9240/Macro_1.scala @@ -5,7 +5,7 @@ inline def diveInto[T]: String = ${ diveIntoImpl[T]() } def diveIntoImpl[T]()(implicit qctx: QuoteContext, ttype: scala.quoted.Type[T]): Expr[String] = import qctx.tasty._ - Expr( unwindType(qctx.tasty)(typeOf[T]) ) + Expr( unwindType(qctx.tasty)(Type.of[T]) ) def unwindType(reflect: Reflection)(aType: reflect.Type): String = import reflect._ diff --git a/tests/pos-macros/i9518/Macro_1.scala b/tests/pos-macros/i9518/Macro_1.scala index 0867f149f559..e824281df824 100644 --- a/tests/pos-macros/i9518/Macro_1.scala +++ b/tests/pos-macros/i9518/Macro_1.scala @@ -12,7 +12,7 @@ def shiftTerm(using QuoteContext): Expr[Unit] = { val tp2 = '[([X] =>> CB[X])[Int]].unseal.tpe val ta = '[[X] =>> CB[X]] val tp3 = '[ta.T[Int]].unseal.tpe - val tp4 = '[CB].unseal.tpe.appliedTo(typeOf[Int]) + val tp4 = '[CB].unseal.tpe.appliedTo(Type.of[Int]) assert(nTree.tpe <:< tp1) assert(nTree.tpe <:< tp2) assert(nTree.tpe <:< tp3) diff --git a/tests/run-macros/i5941/macro_1.scala b/tests/run-macros/i5941/macro_1.scala index 467203dd8957..323a35b22b7a 100644 --- a/tests/run-macros/i5941/macro_1.scala +++ b/tests/run-macros/i5941/macro_1.scala @@ -88,8 +88,8 @@ object Iso { import qctx.tasty._ import util._ - val tpS = typeOf[S] - val tpA = typeOf[A] + val tpS = Type.of[S] + val tpA = Type.of[A] // 1. S must be a case class // 2. A must be a tuple @@ -127,7 +127,7 @@ object Iso { import qctx.tasty._ import util._ - val tpS = typeOf[S] + val tpS = Type.of[S] if (tpS.isSingleton) { val ident = Ident(tpS.asInstanceOf[TermRef]).seal.cast[S] diff --git a/tests/run-macros/i6518/Macro_1.scala b/tests/run-macros/i6518/Macro_1.scala index b68358c83118..216e4fe47f11 100644 --- a/tests/run-macros/i6518/Macro_1.scala +++ b/tests/run-macros/i6518/Macro_1.scala @@ -6,7 +6,7 @@ object Macros { private def testImpl(using qctx: QuoteContext) : Expr[String] = { import qctx.tasty._ - val classSym = typeOf[Function1[_, _]].classSymbol.get + val classSym = Type.ofClass[Function1[_, _]].classSymbol.get classSym.classMethod("apply") classSym.classMethods classSym.method("apply") diff --git a/tests/run-macros/tasty-construct-types/Macro_1.scala b/tests/run-macros/tasty-construct-types/Macro_1.scala index 7b780b4038a6..73f8137f0c98 100644 --- a/tests/run-macros/tasty-construct-types/Macro_1.scala +++ b/tests/run-macros/tasty-construct-types/Macro_1.scala @@ -16,28 +16,28 @@ object Macros { val x1T = ConstantType(Constant(1)) val x2T = OrType(ConstantType(Constant(1)), ConstantType(Constant(2))) - val x3T = AndType(ConstantType(Constant(3)), typeOf[Any]) + val x3T = AndType(ConstantType(Constant(3)), Type.of[Any]) val x4T = TypeLambda( List("A","B"), - _ => List(TypeBounds(typeOf[Nothing], typeOf[Any]), TypeBounds(typeOf[Nothing], typeOf[Any])), + _ => List(TypeBounds(Type.of[Nothing], Type.of[Any]), TypeBounds(Type.of[Nothing], Type.of[Any])), (tl : TypeLambda) => tl.param(1)) val x5T = Refinement( - typeOf[RefineMe], + Type.of[RefineMe], "T", - TypeBounds(typeOf[Int], typeOf[Int])) - val x6T = Type(classOf[List[_]]).appliedTo(List(typeOf[Int])) + TypeBounds(Type.of[Int], Type.of[Int])) + val x6T = Type.ofClass[List[_]].appliedTo(List(Type.of[Int])) val x7T = AnnotatedType(ConstantType(Constant(7)), '{ new TestAnnotation }.unseal) val x8T = MatchType( - typeOf[Int], - typeOf[List[8]], + Type.of[Int], + Type.of[List[8]], List( TypeLambda( List("t"), - _ => List(TypeBounds(typeOf[Nothing], typeOf[Any])), - tl => MatchCaseType.appliedTo(List(Type(classOf[List[_]]).appliedTo(tl.param(0)), tl.param(0))))) + _ => List(TypeBounds(Type.of[Nothing], Type.of[Any])), + tl => MatchCaseType.appliedTo(List(Type.ofClass[List[_]].appliedTo(tl.param(0)), tl.param(0))))) ) assert(x1T =:= '[1].unseal.tpe) diff --git a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala index 9bdc2f804982..c7117b5cb438 100644 --- a/tests/run-macros/tasty-create-method-symbol/Macro_1.scala +++ b/tests/run-macros/tasty-create-method-symbol/Macro_1.scala @@ -12,8 +12,8 @@ object Macros { Symbol.currentOwner, "sym1", MethodType(List("a","b"))( - _ => List(typeOf[Int], typeOf[Int]), - _ => typeOf[Int])) + _ => List(Type.of[Int], Type.of[Int]), + _ => Type.of[Int])) assert(sym1.isDefDef) assert(sym1.name == "sym1") val sym1Statements : List[Statement] = List( @@ -29,7 +29,7 @@ object Macros { val sym2 : Symbol = Symbol.newMethod( Symbol.currentOwner, "sym2", - ByNameType(typeOf[Int])) + ByNameType(Type.of[Int])) assert(sym2.isDefDef) assert(sym2.name == "sym2") val sym2Statements : List[Statement] = List( @@ -46,7 +46,7 @@ object Macros { Symbol.currentOwner, "sym3", MethodType(List("a"))( - _ => List(typeOf[Int]), + _ => List(Type.of[Int]), mt => MethodType(List("b"))( _ => List(mt.param(0)), _ => mt.param(0)))) @@ -66,8 +66,8 @@ object Macros { Symbol.currentOwner, "sym4", MethodType(List("x"))( - _ => List(typeOf[Int]), - _ => typeOf[Int])) + _ => List(Type.of[Int]), + _ => Type.of[Int])) assert(sym4.isDefDef) assert(sym4.name == "sym4") val sym4Statements : List[Statement] = List( @@ -88,8 +88,8 @@ object Macros { Symbol.currentOwner, "sym5", MethodType(List("x"))( - _ => List(typeOf[Int]), - _ => typeOf[Int=>Int])) + _ => List(Type.of[Int]), + _ => Type.of[Int=>Int])) assert(sym5.isDefDef) assert(sym5.name == "sym5") val sym5Statements : List[Statement] = List( @@ -101,8 +101,8 @@ object Macros { sym5, "sym51", MethodType(List("x"))( - _ => List(typeOf[Int]), - _ => typeOf[Int])) + _ => List(Type.of[Int]), + _ => Type.of[Int])) Block( List( DefDef(sym51, { @@ -122,14 +122,14 @@ object Macros { Symbol.currentOwner, "sym6_1", MethodType(List("x"))( - _ => List(typeOf[Int]), - _ => typeOf[Int])) + _ => List(Type.of[Int]), + _ => Type.of[Int])) val sym6_2 : Symbol = Symbol.newMethod( Symbol.currentOwner, "sym6_2", MethodType(List("x"))( - _ => List(typeOf[Int]), - _ => typeOf[Int])) + _ => List(Type.of[Int]), + _ => Type.of[Int])) assert(sym6_1.isDefDef) assert(sym6_2.isDefDef) assert(sym6_1.name == "sym6_1") @@ -169,7 +169,7 @@ object Macros { Symbol.currentOwner, "sym7", PolyType(List("T"))( - tp => List(TypeBounds(typeOf[Nothing], typeOf[Any])), + tp => List(TypeBounds(Type.of[Nothing], Type.of[Any])), tp => MethodType(List("t"))( _ => List(tp.param(0)), _ => tp.param(0)))) @@ -182,7 +182,7 @@ object Macros { Some(Typed(x, Inferred(t))) } }), - '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(typeOf[Int]))), List(Literal(Constant(7)))).seal.asInstanceOf[Expr[Int]] } == 7) }.unseal) + '{ assert(${ Apply(TypeApply(Ref(sym7), List(Inferred(Type.of[Int]))), List(Literal(Constant(7)))).seal.asInstanceOf[Expr[Int]] } == 7) }.unseal) Block( sym1Statements ++ diff --git a/tests/run-macros/tasty-simplified/quoted_1.scala b/tests/run-macros/tasty-simplified/quoted_1.scala index c9ef9a10dd43..9311574dce03 100644 --- a/tests/run-macros/tasty-simplified/quoted_1.scala +++ b/tests/run-macros/tasty-simplified/quoted_1.scala @@ -18,7 +18,7 @@ object Macros { loop(tp, Nil).reverse } - val tps = unpackTuple(typeOf[T]) + val tps = unpackTuple(Type.of[T]) Varargs(tps.map(x => Expr(x.show))) } } diff --git a/tests/run-macros/tasty-typeof/Macro_1.scala b/tests/run-macros/tasty-typeof/Macro_1.scala index a3bdde121473..a362a0ee66ed 100644 --- a/tests/run-macros/tasty-typeof/Macro_1.scala +++ b/tests/run-macros/tasty-typeof/Macro_1.scala @@ -7,25 +7,25 @@ object Macros { private def testTypeOfImpl(using qctx: QuoteContext) : Expr[Unit] = { import qctx.tasty._ '{ - assert(${Expr(typeOf[Unit] =:= defn.UnitType)}, "Unit") - assert(${Expr(typeOf[Byte] =:= defn.ByteType)}, "Byte") - assert(${Expr(typeOf[Short] =:= defn.ShortType)}, "Short") - assert(${Expr(typeOf[Int] =:= defn.IntType)}, "Int") - assert(${Expr(typeOf[Long] =:= defn.LongType)}, "Long") - assert(${Expr(typeOf[Float] =:= defn.FloatType)}, "Float") - assert(${Expr(typeOf[Double] =:= defn.DoubleType)}, "Double") - assert(${Expr(typeOf[Char] =:= defn.CharType)}, "Char") - assert(${Expr(typeOf[String] =:= defn.StringType)}, "String") + assert(${Expr(Type.of[Unit] =:= defn.UnitType)}, "Unit") + assert(${Expr(Type.of[Byte] =:= defn.ByteType)}, "Byte") + assert(${Expr(Type.of[Short] =:= defn.ShortType)}, "Short") + assert(${Expr(Type.of[Int] =:= defn.IntType)}, "Int") + assert(${Expr(Type.of[Long] =:= defn.LongType)}, "Long") + assert(${Expr(Type.of[Float] =:= defn.FloatType)}, "Float") + assert(${Expr(Type.of[Double] =:= defn.DoubleType)}, "Double") + assert(${Expr(Type.of[Char] =:= defn.CharType)}, "Char") + assert(${Expr(Type.of[String] =:= defn.StringType)}, "String") - assert(${Expr(typeOf[Any] =:= defn.AnyType)}, "Any") - assert(${Expr(typeOf[AnyRef] =:= defn.AnyRefType)}, "AnyRef") - assert(${Expr(typeOf[AnyVal] =:= defn.AnyValType)}, "AnyVal") - assert(${Expr(typeOf[Object] =:= defn.ObjectType)}, "Object") - assert(${Expr(typeOf[Nothing] =:= defn.NothingType)}, "Nothing") + assert(${Expr(Type.of[Any] =:= defn.AnyType)}, "Any") + assert(${Expr(Type.of[AnyRef] =:= defn.AnyRefType)}, "AnyRef") + assert(${Expr(Type.of[AnyVal] =:= defn.AnyValType)}, "AnyVal") + assert(${Expr(Type.of[Object] =:= defn.ObjectType)}, "Object") + assert(${Expr(Type.of[Nothing] =:= defn.NothingType)}, "Nothing") - println(${Expr(typeOf[List[Int]].show)}) - println(${Expr(typeOf[Macros].show)}) - println(${Expr(typeOf[Macros.type].show)}) + println(${Expr(Type.of[List[Int]].show)}) + println(${Expr(Type.of[Macros].show)}) + println(${Expr(Type.of[Macros.type].show)}) } }