diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala b/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala index c4fcfce1305a..dbc36a22e8e2 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala @@ -3,35 +3,39 @@ package dotty.tools.dotc.tastyreflect import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Flags._ +import dotty.tools.dotc.core.StdNames._ import dotty.tools.dotc.core.Symbols._ +import dotty.tools.dotc.core.Types._ object FromSymbol { - def definition(sym: Symbol)(implicit ctx: Context): tpd.Tree = { - if (sym.is(Package)) packageDef(sym) + def definitionFromSym(sym: Symbol)(implicit ctx: Context): tpd.Tree = { + if (sym.is(Package)) packageDefFromSym(sym) else if (sym == defn.AnyClass) tpd.EmptyTree // FIXME else if (sym == defn.NothingClass) tpd.EmptyTree // FIXME else if (sym.isClass) classDef(sym.asClass) - else if (sym.isType) typeDef(sym.asType) - else if (sym.is(Method)) defDef(sym.asTerm) - else valDef(sym.asTerm) + else if (sym.isType) typeDefFromSym(sym.asType) + else if (sym.is(Method)) defDefFromSym(sym.asTerm) + else valDefFromSym(sym.asTerm) } - def packageDef(sym: Symbol)(implicit ctx: Context): PackageDefinition = PackageDefinitionImpl(sym) + def packageDefFromSym(sym: Symbol)(implicit ctx: Context): PackageDefinition = PackageDefinitionImpl(sym) - def classDef(cls: ClassSymbol)(implicit ctx: Context): tpd.Tree = { - val constrSym = cls.unforcedDecls.find(_.isPrimaryConstructor) - if (!constrSym.exists) return tpd.EmptyTree + def classDef(cls: ClassSymbol)(implicit ctx: Context): tpd.TypeDef = { + val constrSym = cls.unforcedDecls.find(_.isPrimaryConstructor).orElse( + // Dummy constructor for classes such as `` + ctx.newSymbol(cls, nme.CONSTRUCTOR, EmptyFlags, NoType) + ) val constr = tpd.DefDef(constrSym.asTerm) val parents = cls.classParents.map(tpd.TypeTree(_)) - val body = cls.unforcedDecls.filter(!_.isPrimaryConstructor).map(s => definition(s)) + val body = cls.unforcedDecls.filter(!_.isPrimaryConstructor).map(s => definitionFromSym(s)) tpd.ClassDefWithParents(cls, constr, parents, body) } - def typeDef(sym: TypeSymbol)(implicit ctx: Context): tpd.TypeDef = tpd.TypeDef(sym) + def typeDefFromSym(sym: TypeSymbol)(implicit ctx: Context): tpd.TypeDef = tpd.TypeDef(sym) - def defDef(sym: TermSymbol)(implicit ctx: Context): tpd.DefDef = tpd.DefDef(sym) + def defDefFromSym(sym: TermSymbol)(implicit ctx: Context): tpd.DefDef = tpd.DefDef(sym) - def valDef(sym: TermSymbol)(implicit ctx: Context): tpd.ValDef = tpd.ValDef(sym) + def valDefFromSym(sym: TermSymbol)(implicit ctx: Context): tpd.ValDef = tpd.ValDef(sym) } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/StandardDefinitions.scala b/compiler/src/dotty/tools/dotc/tastyreflect/StandardDefinitions.scala new file mode 100644 index 000000000000..ff637da1436f --- /dev/null +++ b/compiler/src/dotty/tools/dotc/tastyreflect/StandardDefinitions.scala @@ -0,0 +1,80 @@ +package dotty.tools.dotc.tastyreflect + +import dotty.tools.dotc.core.Symbols._ + +import dotty.tools.dotc.tastyreflect.FromSymbol._ + +trait StandardDefinitions extends scala.tasty.reflect.StandardDefinitions { + tasty: TastyImpl => + + private implicit def ctx: Context = rootContext + + val definitions: DefinitionsApi = new DefinitionsApi { + + def RootPackage: PackageDef = packageDefFromSym(defn.RootPackage) + + def ScalaPackage: PackageDef = packageDefFromSym(defn.ScalaPackageVal) + + def AnyClass: ClassDef = classDef(defn.AnyClass) + def AnyValClass: ClassDef = classDef(defn.AnyValClass) + def ObjectClass: ClassDef = classDef(defn.ObjectClass) + def AnyRefClass: TypeDef = typeDefFromSym(defn.AnyRefAlias) + def NullClass: ClassDef = classDef(defn.AnyClass) + def NothingClass: ClassDef = classDef(defn.NothingClass) + def UnitClass: ClassDef = classDef(defn.UnitClass) + def ByteClass: ClassDef = classDef(defn.ByteClass) + def ShortClass: ClassDef = classDef(defn.ShortClass) + def CharClass: ClassDef = classDef(defn.CharClass) + def IntClass: ClassDef = classDef(defn.IntClass) + def LongClass: ClassDef = classDef(defn.LongClass) + def FloatClass: ClassDef = classDef(defn.FloatClass) + def DoubleClass: ClassDef = classDef(defn.DoubleClass) + def BooleanClass: ClassDef = classDef(defn.BooleanClass) + def StringClass: ClassDef = classDef(defn.StringClass) + def ClassClass: ClassDef = classDef(defn.ClassClass) + def ArrayClass: ClassDef = classDef(defn.ArrayClass) + def PredefModule: ValDef = valDefFromSym(defn.ScalaPredefModule.asTerm) + + def JavaLangPackage: PackageDef = packageDefFromSym(defn.JavaLangPackageVal) + + def ArrayModule: ValDef = valDefFromSym(defn.ArrayClass.companionModule.asTerm) + + def Array_apply: DefDef = defDefFromSym(defn.Array_apply.asTerm) + def Array_clone: DefDef = defDefFromSym(defn.Array_clone.asTerm) + def Array_length: DefDef = defDefFromSym(defn.Array_length.asTerm) + def Array_update: DefDef = defDefFromSym(defn.Array_update.asTerm) + + def RepeatedParamClass: ClassDef = classDef(defn.RepeatedParamClass) + + def OptionClass: TypeDef = classDef(defn.OptionClass) + def NoneModule: ValDef = valDefFromSym(defn.NoneClass.companionModule.asTerm) + def SomeModule: ValDef = valDefFromSym(defn.SomeClass.companionModule.asTerm) + + def ProductClass: ClassDef = classDef(defn.ProductClass) + def FunctionClass(arity: Int, isImplicit: Boolean = false, isErased: Boolean = false): ClassDef = + classDef(defn.FunctionClass(arity, isImplicit, isErased).asClass) + def TupleClass(arity: Int): ClassDef = classDef(defn.TupleType(arity).classSymbol.asClass) + + + def ScalaPrimitiveValueClasses: List[ClassDef] = + UnitClass :: BooleanClass :: ScalaNumericValueClasses + def ScalaNumericValueClasses: List[ClassDef] = + ByteClass :: ShortClass :: IntClass :: LongClass :: FloatClass :: DoubleClass :: CharClass :: Nil + + def UnitType: Type = defn.UnitType + def ByteType: Type = defn.ByteType + def ShortType: Type = defn.ShortType + def CharType: Type = defn.CharType + def IntType: Type = defn.IntType + def LongType: Type = defn.LongType + def FloatType: Type = defn.FloatType + def DoubleType: Type = defn.DoubleType + def BooleanType: Type = defn.BooleanType + def AnyType: Type = defn.AnyType + def AnyValType: Type = defn.AnyValType + def AnyRefType: Type = defn.AnyRefType + def ObjectType: Type = defn.ObjectType + def NothingType: Type = defn.NothingType + def NullType: Type = defn.NullType + } +} diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala index 45d7e48c6a27..f7b645eb03b7 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala @@ -15,7 +15,9 @@ import scala.quoted import scala.reflect.ClassTag import scala.tasty.util.{Show, ShowExtractors, ShowSourceCode} -class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { self => +import dotty.tools.dotc.tastyreflect.FromSymbol._ + +class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty with StandardDefinitions { self => // ===== Quotes =================================================== @@ -40,7 +42,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s type Context = Contexts.Context def ContextDeco(ctx: Context): ContextAPI = new ContextAPI { - def owner: Definition = FromSymbol.definition(ctx.owner)(ctx) + def owner: Definition = definitionFromSym(ctx.owner)(ctx) def source: java.nio.file.Path = ctx.compilationUnit.source.file.jpath } @@ -86,7 +88,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s } def PackageClauseDeco(pack: PackageClause): PackageClauseAPI = new PackageClauseAPI { - def definition(implicit ctx: Context): Definition = FromSymbol.packageDef(pack.symbol) + def definition(implicit ctx: Context): Definition = packageDefFromSym(pack.symbol) } // ----- Statements ----------------------------------------------- @@ -147,7 +149,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s def name(implicit ctx: Context): String = definition.symbol.name.toString - def owner(implicit ctx: Context): Definition = FromSymbol.definition(definition.symbol.owner) + def owner(implicit ctx: Context): Definition = definitionFromSym(definition.symbol.owner) def flags(implicit ctx: Context): FlagSet = new FlagSet(definition.symbol.flags) @@ -264,11 +266,11 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s def PackageDefDeco(pdef: PackageDef): PackageDefAPI = new PackageDefAPI { - def owner(implicit ctx: Context): PackageDefinition = FromSymbol.packageDef(pdef.symbol.owner) + def owner(implicit ctx: Context): PackageDefinition = packageDefFromSym(pdef.symbol.owner) def members(implicit ctx: Context): List[Statement] = { if (pdef.symbol.is(core.Flags.JavaDefined)) Nil // FIXME should also support java packages - else pdef.symbol.info.decls.iterator.map(FromSymbol.definition).toList + else pdef.symbol.info.decls.iterator.map(definitionFromSym).toList } } @@ -277,7 +279,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s object PackageDef extends PackageDefExtractor { def unapply(x: PackageDef)(implicit ctx: Context): Option[(String, PackageDef)] = x match { case x: PackageDefinition => - Some((x.symbol.name.toString, FromSymbol.packageDef(x.symbol.owner))) + Some((x.symbol.name.toString, packageDefFromSym(x.symbol.owner))) case _ => None } } @@ -825,7 +827,7 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s def unapply(x: Type)(implicit ctx: Context): Option[(Definition, TypeOrBounds /* Type | NoPrefix */)] = x match { case tp: Types.NamedType => tp.designator match { - case sym: Symbol => Some((FromSymbol.definition(sym), tp.prefix)) + case sym: Symbol => Some((definitionFromSym(sym), tp.prefix)) case _ => None } case _ => None diff --git a/library/src/scala/tasty/Tasty.scala b/library/src/scala/tasty/Tasty.scala index 9492156f51ab..e49fa631a101 100644 --- a/library/src/scala/tasty/Tasty.scala +++ b/library/src/scala/tasty/Tasty.scala @@ -1,9 +1,10 @@ package scala.tasty import scala.reflect.ClassTag +import scala.tasty.reflect.StandardDefinitions import scala.tasty.util.Show -abstract class Tasty { tasty => +abstract class Tasty extends StandardDefinitions { tasty => // ===== Quotes =================================================== diff --git a/library/src/scala/tasty/reflect/StandardDefinitions.scala b/library/src/scala/tasty/reflect/StandardDefinitions.scala new file mode 100644 index 000000000000..5c45a34a74ba --- /dev/null +++ b/library/src/scala/tasty/reflect/StandardDefinitions.scala @@ -0,0 +1,208 @@ +package scala.tasty +package reflect + +trait StandardDefinitions { + self: Tasty => + + /** A value containing all standard definitions in [[DefinitionsApi]] + * @group Definitions + */ + val definitions: DefinitionsApi + + /** Defines standard symbols (and types via its base trait). + * @group API + */ + trait DefinitionsApi extends StandardTypes { + + /** The module symbol of root package `_root_`. */ + def RootPackage: PackageDef + + /** The module symbol of package `scala`. */ + def ScalaPackage: PackageDef + + /** The class symbol of core class `scala.Any`. */ + def AnyClass : ClassDef + + /** The class symbol of core class `scala.AnyVal`. */ + def AnyValClass: ClassDef + + /** The class symbol of core class `java.lang.Object`. */ + def ObjectClass: ClassDef + + /** The type symbol of core class `scala.AnyRef`. */ + def AnyRefClass: TypeDef + + /** The class symbol of core class `scala.Null`. */ + def NullClass : ClassDef + + /** The class symbol of core class `scala.Nothing`. */ + def NothingClass: ClassDef + + /** The class symbol of primitive class `scala.Unit`. */ + def UnitClass : ClassDef + + /** The class symbol of primitive class `scala.Byte`. */ + def ByteClass : ClassDef + + /** The class symbol of primitive class `scala.Short`. */ + def ShortClass : ClassDef + + /** The class symbol of primitive class `scala.Char`. */ + def CharClass : ClassDef + + /** The class symbol of primitive class `scala.Int`. */ + def IntClass : ClassDef + + /** The class symbol of primitive class `scala.Long`. */ + def LongClass : ClassDef + + /** The class symbol of primitive class `scala.Float`. */ + def FloatClass : ClassDef + + /** The class symbol of primitive class `scala.Double`. */ + def DoubleClass : ClassDef + + /** The class symbol of primitive class `scala.Boolean`. */ + def BooleanClass: ClassDef + + /** The class symbol of class `scala.String`. */ + def StringClass : ClassDef + + /** The class symbol of class `java.lang.Class`. */ + def ClassClass : ClassDef + + /** The class symbol of class `scala.Array`. */ + def ArrayClass : ClassDef + + /** The module symbol of module `scala.Predef`. */ + def PredefModule: ValDef + + /** The module symbol of package `java.lang`. */ + def JavaLangPackage: PackageDef + + /** The module symbol of module `scala.Array`. */ + def ArrayModule: ValDef + + /** The method symbol of method `apply` in class `scala.Array`. */ + def Array_apply: DefDef + + /** The method symbol of method `clone` in class `scala.Array`. */ + def Array_clone: DefDef + + /** The method symbol of method `length` in class `scala.Array`. */ + def Array_length: DefDef + + /** The method symbol of method `update` in class `scala.Array`. */ + def Array_update: DefDef + + /** A dummy class symbol that is used to indicate repeated parameters + * compiled by the Scala compiler. + */ + def RepeatedParamClass: ClassDef + + /** The class symbol of class `scala.Option`. */ + def OptionClass: ClassDef + + /** The module symbol of module `scala.None`. */ + def NoneModule: ValDef + + /** The module symbol of module `scala.Some`. */ + def SomeModule: ValDef + + /** Function-like object that maps arity to symbols for classes `scala.Product` */ + def ProductClass: ClassDef + + /** Function-like object that maps arity to symbols for classes `scala.FunctionX`. + * - 0th element is `Function0` + * - 1st element is `Function1` + * - ... + * - Nth element is `FunctionN` + */ + def FunctionClass(arity: Int, isImplicit: Boolean = false, isErased: Boolean = false): ClassDef + + /** Function-like object that maps arity to symbols for classes `scala.TupleX`. + * - 0th element is `NoSymbol` + * - 1st element is `NoSymbol` + * - 2st element is `Tuple2` + * - ... + * - 22nd element is `Tuple22` + * - 23nd element is `NoSymbol` // TODO update when we will have more tuples + * - ... + */ + def TupleClass(arity: Int): ClassDef + + /** Contains Scala primitive value classes: + * - Byte + * - Short + * - Int + * - Long + * - Float + * - Double + * - Char + * - Boolean + * - Unit + */ + def ScalaPrimitiveValueClasses: List[ClassDef] + + /** Contains Scala numeric value classes: + * - Byte + * - Short + * - Int + * - Long + * - Float + * - Double + * - Char + */ + def ScalaNumericValueClasses: List[ClassDef] + } + + /** Defines standard types. + * @group Definitions + */ + trait StandardTypes { + /** The type of primitive type `Unit`. */ + def UnitType: Type + + /** The type of primitive type `Byte`. */ + def ByteType: Type + + /** The type of primitive type `Short`. */ + def ShortType: Type + + /** The type of primitive type `Char`. */ + def CharType: Type + + /** The type of primitive type `Int`. */ + def IntType: Type + + /** The type of primitive type `Long`. */ + def LongType: Type + + /** The type of primitive type `Float`. */ + def FloatType: Type + + /** The type of primitive type `Double`. */ + def DoubleType: Type + + /** The type of primitive type `Boolean`. */ + def BooleanType: Type + + /** The type of core type `Any`. */ + def AnyType: Type + + /** The type of core type `AnyVal`. */ + def AnyValType: Type + + /** The type of core type `AnyRef`. */ + def AnyRefType: Type + + /** The type of core type `Object`. */ + def ObjectType: Type + + /** The type of core type `Nothing`. */ + def NothingType: Type + + /** The type of core type `Null`. */ + def NullType: Type + } +} diff --git a/tests/run/tasty-definitions.check b/tests/run/tasty-definitions.check new file mode 100644 index 000000000000..b5999767345a --- /dev/null +++ b/tests/run/tasty-definitions.check @@ -0,0 +1,171 @@ +_root_ +scala +Any +AnyVal +Object +AnyRef +Any +Nothing +Unit +Byte +Short +Char +Int +Long +Float +Double +Boolean +String +Class +Array +Predef +lang +Array +apply +clone +length +update + +Option +None +Some +Product +Function0 +Function1 +Function2 +Function3 +Function4 +Function5 +Function6 +Function7 +Function8 +Function9 +Function10 +Function11 +Function12 +Function13 +Function14 +Function15 +Function16 +Function17 +Function18 +Function19 +Function20 +Function21 +Function22 +Function23 +Function24 +Function25 +ImplicitFunction0 +ImplicitFunction1 +ImplicitFunction2 +ImplicitFunction3 +ImplicitFunction4 +ImplicitFunction5 +ImplicitFunction6 +ImplicitFunction7 +ImplicitFunction8 +ImplicitFunction9 +ImplicitFunction10 +ImplicitFunction11 +ImplicitFunction12 +ImplicitFunction13 +ImplicitFunction14 +ImplicitFunction15 +ImplicitFunction16 +ImplicitFunction17 +ImplicitFunction18 +ImplicitFunction19 +ImplicitFunction20 +ImplicitFunction21 +ImplicitFunction22 +ImplicitFunction23 +ImplicitFunction24 +ImplicitFunction25 +ErasedFunction1 +ErasedFunction2 +ErasedFunction3 +ErasedFunction4 +ErasedFunction5 +ErasedFunction6 +ErasedFunction7 +ErasedFunction8 +ErasedFunction9 +ErasedFunction10 +ErasedFunction11 +ErasedFunction12 +ErasedFunction13 +ErasedFunction14 +ErasedFunction15 +ErasedFunction16 +ErasedFunction17 +ErasedFunction18 +ErasedFunction19 +ErasedFunction20 +ErasedFunction21 +ErasedFunction22 +ErasedFunction23 +ErasedFunction24 +ErasedFunction25 +ErasedImplicitFunction1 +ErasedImplicitFunction2 +ErasedImplicitFunction3 +ErasedImplicitFunction4 +ErasedImplicitFunction5 +ErasedImplicitFunction6 +ErasedImplicitFunction7 +ErasedImplicitFunction8 +ErasedImplicitFunction9 +ErasedImplicitFunction10 +ErasedImplicitFunction11 +ErasedImplicitFunction12 +ErasedImplicitFunction13 +ErasedImplicitFunction14 +ErasedImplicitFunction15 +ErasedImplicitFunction16 +ErasedImplicitFunction17 +ErasedImplicitFunction18 +ErasedImplicitFunction19 +ErasedImplicitFunction20 +ErasedImplicitFunction21 +ErasedImplicitFunction22 +ErasedImplicitFunction23 +ErasedImplicitFunction24 +ErasedImplicitFunction25 +Tuple2 +Tuple3 +Tuple4 +Tuple5 +Tuple6 +Tuple7 +Tuple8 +Tuple9 +Tuple10 +Tuple11 +Tuple12 +Tuple13 +Tuple14 +Tuple15 +Tuple16 +Tuple17 +Tuple18 +Tuple19 +Tuple20 +Tuple21 +Tuple22 +List(Unit, Boolean, Byte, Short, Int, Long, Float, Double, Char) +List(Byte, Short, Int, Long, Float, Double, Char) +Type.SymRef(ClassDef("Unit", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Byte", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Char", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Int", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Long", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Float", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Double", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Boolean", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(#, Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("AnyVal", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(TypeDef("AnyRef", _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Object", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("lang", _), NoPrefix()))) +Type.SymRef(#, Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) +Type.SymRef(ClassDef("Null", _, _, _, _), Type.ThisType(Type.SymRef(PackageDef("scala", _), NoPrefix()))) diff --git a/tests/run/tasty-definitions/quoted_1.scala b/tests/run/tasty-definitions/quoted_1.scala new file mode 100644 index 000000000000..5d88c186b0f4 --- /dev/null +++ b/tests/run/tasty-definitions/quoted_1.scala @@ -0,0 +1,100 @@ +import scala.quoted._ + +import scala.tasty._ +import scala.tasty.util.TreeTraverser + +object Macros { + + transparent def testDefinitions(): Unit = + ~testDefinitionsImpl(TopLevelSplice.tastyContext) // FIXME infer TopLevelSplice.tastyContext within top level ~ + + def testDefinitionsImpl(implicit tasty: Tasty): Expr[Unit] = { + import tasty._ + + val buff = List.newBuilder[String] + def printout(x: => String): Unit = { + + buff += (try x catch { case ex => ex.getClass + ": " + ex.getMessage}) + } + + printout(definitions.RootPackage.name) + printout(definitions.ScalaPackage.name) + + printout(definitions.AnyClass.name) + printout(definitions.AnyValClass.name) + printout(definitions.ObjectClass.name) + printout(definitions.AnyRefClass.name) + + printout(definitions.NullClass.name) + printout(definitions.NothingClass.name) + + printout(definitions.UnitClass.name) + printout(definitions.ByteClass.name) + printout(definitions.ShortClass.name) + printout(definitions.CharClass.name) + printout(definitions.IntClass.name) + printout(definitions.LongClass.name) + printout(definitions.FloatClass.name) + printout(definitions.DoubleClass.name) + printout(definitions.BooleanClass.name) + + printout(definitions.StringClass.name) + printout(definitions.ClassClass.name) + printout(definitions.ArrayClass.name) + printout(definitions.PredefModule.name) + + printout(definitions.JavaLangPackage.name) + + printout(definitions.ArrayModule.name) + + printout(definitions.Array_apply.name) + printout(definitions.Array_clone.name) + printout(definitions.Array_length.name) + printout(definitions.Array_update.name) + + printout(definitions.RepeatedParamClass.name) + + printout(definitions.OptionClass.name) + printout(definitions.NoneModule.name) + printout(definitions.SomeModule.name) + + printout(definitions.ProductClass.name) + + for (i <- 0 to 25) + printout(definitions.FunctionClass(i).name) + + for (i <- 0 to 25) + printout(definitions.FunctionClass(i, isImplicit = true).name) + + for (i <- 1 to 25) + printout(definitions.FunctionClass(i, isErased = true).name) + + for (i <- 1 to 25) + printout(definitions.FunctionClass(i, isImplicit = true, isErased = true).name) + + for (i <- 2 to 22) + printout(definitions.TupleClass(i).name) + + printout(definitions.ScalaPrimitiveValueClasses.map(_.name).toString) + printout(definitions.ScalaNumericValueClasses.map(_.name).toString) + + printout(definitions.UnitType.show) + printout(definitions.ByteType.show) + printout(definitions.CharType.show) + printout(definitions.IntType.show) + printout(definitions.LongType.show) + printout(definitions.FloatType.show) + printout(definitions.DoubleType.show) + printout(definitions.BooleanType.show) + printout(definitions.AnyType.show) + printout(definitions.AnyValType.show) + printout(definitions.AnyRefType.show) + printout(definitions.ObjectType.show) + printout(definitions.NothingType.show) + printout(definitions.NullType.show) + + + '(println(~buff.result().mkString("\n").toExpr)) + } + +} diff --git a/tests/run/tasty-definitions/quoted_2.scala b/tests/run/tasty-definitions/quoted_2.scala new file mode 100644 index 000000000000..c3824598782c --- /dev/null +++ b/tests/run/tasty-definitions/quoted_2.scala @@ -0,0 +1,6 @@ + +object Test { + def main(args: Array[String]): Unit = { + Macros.testDefinitions() + } +}