diff --git a/community-build/community-projects/sourcecode b/community-build/community-projects/sourcecode index 58f0d4d6c672..94d81945b199 160000 --- a/community-build/community-projects/sourcecode +++ b/community-build/community-projects/sourcecode @@ -1 +1 @@ -Subproject commit 58f0d4d6c67211337c795e2c208d261280cd5a3e +Subproject commit 94d81945b1993d7651ce06c1f27f639cea8f8d78 diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala b/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala index e327a97fdf52..040626b248a9 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala @@ -14,6 +14,7 @@ object FromSymbol { assert(sym.exists) if (sym.is(Package)) packageDefFromSym(sym) else if (sym.isClass) classDef(sym.asClass) + else if (sym.isType && sym.is(Case)) typeBindFromSym(sym.asType) else if (sym.isType) typeDefFromSym(sym.asType) else if (sym.is(Method)) defDefFromSym(sym.asTerm) else if (sym.is(Case)) bindFromSym(sym.asTerm) @@ -54,4 +55,9 @@ object FromSymbol { case tree: tpd.Bind => tree case tpd.EmptyTree => tpd.Bind(sym, untpd.Ident(nme.WILDCARD).withType(sym.typeRef)) } + + def typeBindFromSym(sym: TypeSymbol)(implicit ctx: Context): tpd.Bind = sym.defTree match { + case tree: tpd.Bind => tree + case tpd.EmptyTree => tpd.Bind(sym, untpd.Ident(nme.WILDCARD).withType(sym.typeRef)) + } } diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala index f976ee86e132..5ea4b8aa21a7 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala @@ -123,7 +123,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. else self.symbol.info.decls.iterator.map(definitionFromSym).toList } - def PackageDef_symbol(self: PackageDef)(implicit ctx: Context): PackageSymbol = self.symbol + def PackageDef_symbol(self: PackageDef)(implicit ctx: Context): PackageDefSymbol = self.symbol type ClassDef = tpd.TypeDef @@ -137,7 +137,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def ClassDef_derived(self: ClassDef)(implicit ctx: Context): List[TypeTree] = ClassDef_rhs(self).derived.asInstanceOf[List[TypeTree]] def ClassDef_self(self: ClassDef)(implicit ctx: Context): Option[ValDef] = optional(ClassDef_rhs(self).self) def ClassDef_body(self: ClassDef)(implicit ctx: Context): List[Statement] = ClassDef_rhs(self).body - def ClassDef_symbol(self: ClassDef)(implicit ctx: Context): ClassSymbol = self.symbol.asClass + def ClassDef_symbol(self: ClassDef)(implicit ctx: Context): ClassDefSymbol = self.symbol.asClass private def ClassDef_rhs(self: ClassDef) = self.rhs.asInstanceOf[tpd.Template] def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree /* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(implicit ctx: Context): ClassDef = { @@ -153,9 +153,9 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. } def TypeDef_rhs(self: TypeDef)(implicit ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = self.rhs - def TypeDef_symbol(self: TypeDef)(implicit ctx: Context): TypeSymbol = self.symbol.asType + def TypeDef_symbol(self: TypeDef)(implicit ctx: Context): TypeDefSymbol = self.symbol.asType - def TypeDef_apply(symbol: TypeSymbol)(implicit ctx: Context): TypeDef = withDefaultPos(ctx => tpd.TypeDef(symbol)(ctx)) + def TypeDef_apply(symbol: TypeDefSymbol)(implicit ctx: Context): TypeDef = withDefaultPos(ctx => tpd.TypeDef(symbol)(ctx)) def TypeDef_copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(implicit ctx: Context): TypeDef = tpd.cpy.TypeDef(original)(name.toTypeName, rhs) @@ -170,9 +170,9 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def DefDef_paramss(self: DefDef)(implicit ctx: Context): List[List[ValDef]] = self.vparamss def DefDef_returnTpt(self: DefDef)(implicit ctx: Context): TypeTree = self.tpt def DefDef_rhs(self: DefDef)(implicit ctx: Context): Option[Tree] = optional(self.rhs) - def DefDef_symbol(self: DefDef)(implicit ctx: Context): DefSymbol = self.symbol.asTerm + def DefDef_symbol(self: DefDef)(implicit ctx: Context): DefDefSymbol = self.symbol.asTerm - def DefDef_apply(symbol: DefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef = + def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef = withDefaultPos(ctx => tpd.polyDefDef(symbol, tparams => vparamss => rhsFn(tparams)(vparamss).getOrElse(tpd.EmptyTree))(ctx)) def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): DefDef = @@ -187,9 +187,9 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def ValDef_tpt(self: ValDef)(implicit ctx: Context): TypeTree = self.tpt def ValDef_rhs(self: ValDef)(implicit ctx: Context): Option[Tree] = optional(self.rhs) - def ValDef_symbol(self: ValDef)(implicit ctx: Context): ValSymbol = self.symbol.asTerm + def ValDef_symbol(self: ValDef)(implicit ctx: Context): ValDefSymbol = self.symbol.asTerm - def ValDef_apply(symbol: ValSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef = + def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef = tpd.ValDef(symbol, rhs.getOrElse(tpd.EmptyTree)) def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): ValDef = @@ -278,7 +278,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def This_id(self: This)(implicit ctx: Context): Option[Id] = optional(self.qual) - def This_apply(cls: ClassSymbol)(implicit ctx: Context): This = + def This_apply(cls: ClassDefSymbol)(implicit ctx: Context): This = withDefaultPos(ctx => tpd.This(cls)(ctx)) def This_copy(original: Tree)(qual: Option[Id])(implicit ctx: Context): This = @@ -996,7 +996,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def Type_dealias(self: Type)(implicit ctx: Context): Type = self.dealias - def Type_classSymbol(self: Type)(implicit ctx: Context): Option[ClassSymbol] = + def Type_classSymbol(self: Type)(implicit ctx: Context): Option[ClassDefSymbol] = if (self.classSymbol.exists) Some(self.classSymbol.asClass) else None def Type_typeSymbol(self: Type)(implicit ctx: Context): Symbol = self.typeSymbol @@ -1427,49 +1427,54 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. def Symbol_isAbstractType(self: Symbol)(implicit ctx: Context): Boolean = self.isAbstractType def Symbol_isClassConstructor(self: Symbol)(implicit ctx: Context): Boolean = self.isClassConstructor - type PackageSymbol = core.Symbols.Symbol + type PackageDefSymbol = core.Symbols.Symbol - def matchPackageSymbol(symbol: Symbol)(implicit ctx: Context): Option[PackageSymbol] = + def matchPackageDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[PackageDefSymbol] = if (symbol.is(core.Flags.Package)) Some(symbol) else None - def PackageSymbol_tree(self: PackageSymbol)(implicit ctx: Context): PackageDef = + def PackageDefSymbol_tree(self: PackageDefSymbol)(implicit ctx: Context): PackageDef = FromSymbol.packageDefFromSym(self) - type ClassSymbol = core.Symbols.ClassSymbol + type TypeSymbol = core.Symbols.TypeSymbol + + def matchTypeSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] = + if (symbol.isType) Some(symbol.asType) else None + + type ClassDefSymbol = core.Symbols.ClassSymbol - def matchClassSymbol(symbol: Symbol)(implicit ctx: Context): Option[ClassSymbol] = + def matchClassDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[ClassDefSymbol] = if (symbol.isClass) Some(symbol.asClass) else None - def ClassSymbol_tree(self: ClassSymbol)(implicit ctx: Context): ClassDef = + def ClassDefSymbol_tree(self: ClassDefSymbol)(implicit ctx: Context): ClassDef = FromSymbol.classDef(self) - def ClassSymbol_fields(self: Symbol)(implicit ctx: Context): List[Symbol] = + def ClassDefSymbol_fields(self: Symbol)(implicit ctx: Context): List[Symbol] = self.unforcedDecls.filter(isField) - def ClassSymbol_field(self: Symbol)(name: String)(implicit ctx: Context): Option[Symbol] = { + def ClassDefSymbol_field(self: Symbol)(name: String)(implicit ctx: Context): Option[Symbol] = { val sym = self.unforcedDecls.find(sym => sym.name == name.toTermName) if (sym.exists && isField(sym)) Some(sym) else None } - def ClassSymbol_classMethod(self: Symbol)(name: String)(implicit ctx: Context): List[DefSymbol] = { + def ClassDefSymbol_classMethod(self: Symbol)(name: String)(implicit ctx: Context): List[DefDefSymbol] = { self.typeRef.decls.iterator.collect { case sym if isMethod(sym) && sym.name.toString == name => sym.asTerm }.toList } - def ClassSymbol_classMethods(self: Symbol)(implicit ctx: Context): List[DefSymbol] = { + def ClassDefSymbol_classMethods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] = { self.typeRef.decls.iterator.collect { case sym if isMethod(sym) => sym.asTerm }.toList } - def ClassSymbol_method(self: Symbol)(name: String)(implicit ctx: Context): List[DefSymbol] = { + def ClassDefSymbol_method(self: Symbol)(name: String)(implicit ctx: Context): List[DefDefSymbol] = { self.typeRef.allMembers.iterator.map(_.symbol).collect { case sym if isMethod(sym) && sym.name.toString == name => sym.asTerm }.toList } - def ClassSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefSymbol] = { + def ClassDefSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] = { self.typeRef.allMembers.iterator.map(_.symbol).collect { case sym if isMethod(sym) => sym.asTerm }.toList @@ -1478,67 +1483,80 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util. private def isMethod(sym: Symbol)(implicit ctx: Context): Boolean = sym.isTerm && sym.is(Flags.Method) && !sym.isConstructor - def ClassSymbol_caseFields(self: Symbol)(implicit ctx: Context): List[ValSymbol] = { + def ClassDefSymbol_caseFields(self: Symbol)(implicit ctx: Context): List[ValDefSymbol] = { if (!self.isClass) Nil else self.asClass.paramAccessors.collect { case sym if sym.is(Flags.CaseAccessor) => sym.asTerm } } - def ClassSymbol_companionClass(self: Symbol)(implicit ctx: Context): Option[ClassSymbol] = { + def ClassDefSymbol_companionClass(self: Symbol)(implicit ctx: Context): Option[ClassDefSymbol] = { val sym = self.companionModule.companionClass if (sym.exists) Some(sym.asClass) else None } - def ClassSymbol_companionModule(self: Symbol)(implicit ctx: Context): Option[ValSymbol] = { + def ClassDefSymbol_companionModule(self: Symbol)(implicit ctx: Context): Option[ValDefSymbol] = { val sym = self.companionModule if (sym.exists) Some(sym.asTerm) else None } - def ClassSymbol_moduleClass(self: Symbol)(implicit ctx: Context): Option[Symbol] = { + def ClassDefSymbol_moduleClass(self: Symbol)(implicit ctx: Context): Option[Symbol] = { val sym = self.moduleClass if (sym.exists) Some(sym.asTerm) else None } private def isField(sym: Symbol)(implicit ctx: Context): Boolean = sym.isTerm && !sym.is(Flags.Method) - def ClassSymbol_of(fullName: String)(implicit ctx: Context): ClassSymbol = ctx.requiredClass(fullName) + def ClassDefSymbol_of(fullName: String)(implicit ctx: Context): ClassDefSymbol = ctx.requiredClass(fullName) - type TypeSymbol = core.Symbols.TypeSymbol + type TypeDefSymbol = core.Symbols.TypeSymbol - def matchTypeSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] = + def matchTypeDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeDefSymbol] = if (symbol.isType) Some(symbol.asType) else None - def TypeSymbol_tree(self: TypeSymbol)(implicit ctx: Context): TypeDef = + def TypeDefSymbol_tree(self: TypeDefSymbol)(implicit ctx: Context): TypeDef = FromSymbol.typeDefFromSym(self) - def TypeSymbol_isTypeParam(self: TypeSymbol)(implicit ctx: Context): Boolean = + def TypeDefSymbol_isTypeParam(self: TypeDefSymbol)(implicit ctx: Context): Boolean = self.isTypeParam - type DefSymbol = core.Symbols.TermSymbol + type TypeBindSymbol = core.Symbols.TypeSymbol + + def matchTypeBindSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeBindSymbol] = + if (symbol.isType && symbol.is(core.Flags.Case)) Some(symbol.asType) else None + + def TypeBindSymbol_tree(self: TypeBindSymbol)(implicit ctx: Context): TypeTree_TypeBind = + FromSymbol.typeBindFromSym(self) + + type TermSymbol = core.Symbols.TermSymbol + + def matchTermSymbol(symbol: Symbol)(implicit ctx: Context): Option[TermSymbol] = + if (symbol.isTerm) Some(symbol.asTerm) else None + + type DefDefSymbol = core.Symbols.TermSymbol - def matchDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[DefSymbol] = + def matchDefDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[DefDefSymbol] = if (symbol.isTerm && symbol.is(core.Flags.Method)) Some(symbol.asTerm) else None - def DefSymbol_tree(self: DefSymbol)(implicit ctx: Context): DefDef = + def DefDefSymbol_tree(self: DefDefSymbol)(implicit ctx: Context): DefDef = FromSymbol.defDefFromSym(self) - def DefSymbol_signature(self: DefSymbol)(implicit ctx: Context): Signature = + def DefDefSymbol_signature(self: DefDefSymbol)(implicit ctx: Context): Signature = self.signature - type ValSymbol = core.Symbols.TermSymbol + type ValDefSymbol = core.Symbols.TermSymbol - def matchValSymbol(symbol: Symbol)(implicit ctx: Context): Option[ValSymbol] = + def matchValDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[ValDefSymbol] = if (symbol.isTerm && !symbol.is(core.Flags.Method) && !symbol.is(core.Flags.Case)) Some(symbol.asTerm) else None - def ValSymbol_tree(self: ValSymbol)(implicit ctx: Context): ValDef = + def ValDefSymbol_tree(self: ValDefSymbol)(implicit ctx: Context): ValDef = FromSymbol.valDefFromSym(self) - def ValSymbol_moduleClass(self: ValSymbol)(implicit ctx: Context): Option[ClassSymbol] = { + def ValDefSymbol_moduleClass(self: ValDefSymbol)(implicit ctx: Context): Option[ClassDefSymbol] = { val sym = self.moduleClass if (sym.exists) Some(sym.asClass) else None } - def ValSymbol_companionClass(self: ValSymbol)(implicit ctx: Context): Option[ClassSymbol] = { + def ValDefSymbol_companionClass(self: ValDefSymbol)(implicit ctx: Context): Option[ClassDefSymbol] = { val sym = self.companionClass if (sym.exists) Some(sym.asClass) else None } diff --git a/docs/docs/reference/other-new-features/tasty-reflect.md b/docs/docs/reference/other-new-features/tasty-reflect.md index eacbc2b16625..ca44c0d6c6b8 100644 --- a/docs/docs/reference/other-new-features/tasty-reflect.md +++ b/docs/docs/reference/other-new-features/tasty-reflect.md @@ -177,11 +177,12 @@ TASTy Reflect provides the following types: +- Constant -+- Symbol --+- PackageSymbol - +- ClassSymbol - +- TypeSymbol - +- DefSymbol - +- ValSymbol ++- Symbol --+- PackageDefSymbol + +- ClassDefSymbol + +- TypeDefSymbol + +- TypeBindSymbol + +- DefDefSymbol + +- ValDefSymbol +- BindSymbol +- NoSymbol diff --git a/library/src/scala/tasty/reflect/Core.scala b/library/src/scala/tasty/reflect/Core.scala index 40c54cb5b66c..d1e6fb4709bc 100644 --- a/library/src/scala/tasty/reflect/Core.scala +++ b/library/src/scala/tasty/reflect/Core.scala @@ -100,12 +100,16 @@ package scala.tasty.reflect * * +- Constant * - * +- Symbol --+- PackageSymbol - * +- ClassSymbol - * +- TypeSymbol - * +- DefSymbol - * +- ValSymbol - * +- BindSymbol + * +- Symbol --+- PackageDefSymbol + * | + * +- TypeSymbol -+- ClassDefSymbol + * | +- TypeDefSymbol + * | +- TypeBindSymbol + * | + * +- TermSymbol -+- DefDefSymbol + * | +- ValDefSymbol + * | +- BindSymbol + * | * +- NoSymbol * * +- Flags @@ -418,22 +422,31 @@ trait Core { type Symbol = kernel.Symbol /** Symbol of a package definition */ - type PackageSymbol = kernel.PackageSymbol + type PackageDefSymbol = kernel.PackageDefSymbol - /** Symbol of a class definition. This includes anonymous class definitions and the class of a module object. */ - type ClassSymbol = kernel.ClassSymbol - - /** Symbol of a type (parameter or member) definition. */ + /** Symbol representing a type definition. */ type TypeSymbol = kernel.TypeSymbol - /** Symbol representing a method definition. */ - type DefSymbol = kernel.DefSymbol + /** Symbol of a class definition. This includes anonymous class definitions and the class of a module object. */ + type ClassDefSymbol = kernel.ClassDefSymbol + + /** Symbol of a type (parameter or member) definition. */ + type TypeDefSymbol = kernel.TypeDefSymbol + + /** Symbol representing a type bind definition. */ + type TypeBindSymbol = kernel.TypeBindSymbol + + /** Symbol representing a term definition. */ + type TermSymbol = kernel.TermSymbol + + /** Symbol representing a method definition. */ + type DefDefSymbol = kernel.DefDefSymbol - /** Symbol representing a value definition. This includes `val`, `lazy val`, `var`, `object` and parameter definitions. */ - type ValSymbol = kernel.ValSymbol + /** Symbol representing a value definition. This includes `val`, `lazy val`, `var`, `object` and parameter definitions. */ + type ValDefSymbol = kernel.ValDefSymbol - /** Symbol representing a bind definition. */ - type BindSymbol = kernel.BindSymbol + /** Symbol representing a bind definition. */ + type BindSymbol = kernel.BindSymbol /** No symbol available. */ type NoSymbol = kernel.NoSymbol diff --git a/library/src/scala/tasty/reflect/Kernel.scala b/library/src/scala/tasty/reflect/Kernel.scala index 44d8e163bd4b..38c605ccfc6b 100644 --- a/library/src/scala/tasty/reflect/Kernel.scala +++ b/library/src/scala/tasty/reflect/Kernel.scala @@ -99,12 +99,16 @@ package scala.tasty.reflect * * +- Constant * - * +- Symbol --+- PackageSymbol - * +- ClassSymbol - * +- TypeSymbol - * +- DefSymbol - * +- ValSymbol - * +- BindSymbol + * +- Symbol --+- PackageDefSymbol + * | + * +- TypeSymbol -+- ClassDefSymbol + * | +- TypeDefSymbol + * | +- TypeBindSymbol + * | + * +- TermSymbol -+- DefDefSymbol + * | +- ValDefSymbol + * | +- BindSymbol + * | * +- NoSymbol * * +- Flags @@ -207,7 +211,7 @@ trait Kernel { def PackageDef_owner(self: PackageDef)(implicit ctx: Context): PackageDef def PackageDef_members(self: PackageDef)(implicit ctx: Context): List[Statement] - def PackageDef_symbol(self: PackageDef)(implicit ctx: Context): PackageSymbol + def PackageDef_symbol(self: PackageDef)(implicit ctx: Context): PackageDefSymbol /** Tree representing a class definition. This includes annonymus class definitions and the class of a module object */ type ClassDef <: Definition @@ -219,7 +223,7 @@ trait Kernel { def ClassDef_derived(self: ClassDef)(implicit ctx: Context): List[TypeTree] def ClassDef_self(self: ClassDef)(implicit ctx: Context): Option[ValDef] def ClassDef_body(self: ClassDef)(implicit ctx: Context): List[Statement] - def ClassDef_symbol(self: ClassDef)(implicit ctx: Context): ClassSymbol + def ClassDef_symbol(self: ClassDef)(implicit ctx: Context): ClassDefSymbol def ClassDef_copy(original: ClassDef)(name: String, constr: DefDef, parents: List[Tree/* Term | TypeTree */], derived: List[TypeTree], selfOpt: Option[ValDef], body: List[Statement])(implicit ctx: Context): ClassDef @@ -229,9 +233,9 @@ trait Kernel { def matchTypeDef(tree: Tree)(implicit ctx: Context): Option[TypeDef] def TypeDef_rhs(self: TypeDef)(implicit ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ - def TypeDef_symbol(self: TypeDef)(implicit ctx: Context): TypeSymbol + def TypeDef_symbol(self: TypeDef)(implicit ctx: Context): TypeDefSymbol - def TypeDef_apply(symbol: TypeSymbol)(implicit ctx: Context): TypeDef + def TypeDef_apply(symbol: TypeDefSymbol)(implicit ctx: Context): TypeDef def TypeDef_copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(implicit ctx: Context): TypeDef /** Tree representing a method definition in the source code */ @@ -243,21 +247,21 @@ trait Kernel { def DefDef_paramss(self: DefDef)(implicit ctx: Context): List[List[ValDef]] def DefDef_returnTpt(self: DefDef)(implicit ctx: Context): TypeTree def DefDef_rhs(self: DefDef)(implicit ctx: Context): Option[Term] - def DefDef_symbol(self: DefDef)(implicit ctx: Context): DefSymbol + def DefDef_symbol(self: DefDef)(implicit ctx: Context): DefDefSymbol - def DefDef_apply(symbol: DefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef + def DefDef_apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef def DefDef_copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): DefDef - /** Tree representing a value definition in the source code This inclues `val`, `lazy val`, `var`, `object` and parameter defintions. */ + /** Tree representing a value definition in the source code This inclues `val`, `lazy val`, `var`, `object` and parameter definitions. */ type ValDef <: Definition def matchValDef(tree: Tree)(implicit ctx: Context): Option[ValDef] def ValDef_tpt(self: ValDef)(implicit ctx: Context): TypeTree def ValDef_rhs(self: ValDef)(implicit ctx: Context): Option[Term] - def ValDef_symbol(self: ValDef)(implicit ctx: Context): ValSymbol + def ValDef_symbol(self: ValDef)(implicit ctx: Context): ValDefSymbol - def ValDef_apply(symbol: ValSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef + def ValDef_apply(symbol: ValDefSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef def ValDef_copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): ValDef /** Tree representing an expression in the source code */ @@ -316,7 +320,7 @@ trait Kernel { def This_id(self: This)(implicit ctx: Context): Option[Id] - def This_apply(cls: ClassSymbol)(implicit ctx: Context): This + def This_apply(cls: ClassDefSymbol)(implicit ctx: Context): This def This_copy(original: Tree)(qual: Option[Id])(implicit ctx: Context): This /** Tree representing `new` in the source code */ @@ -802,7 +806,7 @@ trait Kernel { */ def Type_dealias(self: Type)(implicit ctx: Context): Type - def Type_classSymbol(self: Type)(implicit ctx: Context): Option[ClassSymbol] + def Type_classSymbol(self: Type)(implicit ctx: Context): Option[ClassDefSymbol] def Type_typeSymbol(self: Type)(implicit ctx: Context): Symbol @@ -1166,88 +1170,104 @@ trait Kernel { def Symbol_isDefinedInCurrentRun(self: Symbol)(implicit ctx: Context): Boolean /** Symbol of a package definition */ - type PackageSymbol <: Symbol + type PackageDefSymbol <: Symbol - def matchPackageSymbol(symbol: Symbol)(implicit ctx: Context): Option[PackageSymbol] + def matchPackageDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[PackageDefSymbol] - def PackageSymbol_tree(self: PackageSymbol)(implicit ctx: Context): PackageDef + def PackageDefSymbol_tree(self: PackageDefSymbol)(implicit ctx: Context): PackageDef + + type TypeSymbol <: Symbol + + def matchTypeSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] /** Symbol of a class definition. This includes anonymous class definitions and the class of a module object. */ - type ClassSymbol <: Symbol + type ClassDefSymbol <: TypeSymbol - def matchClassSymbol(symbol: Symbol)(implicit ctx: Context): Option[ClassSymbol] + def matchClassDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[ClassDefSymbol] - /** ClassDef tree of this defintion */ - def ClassSymbol_tree(self: ClassSymbol)(implicit ctx: Context): ClassDef + /** ClassDef tree of this definition */ + def ClassDefSymbol_tree(self: ClassDefSymbol)(implicit ctx: Context): ClassDef /** Fields directly declared in the class */ - def ClassSymbol_fields(self: Symbol)(implicit ctx: Context): List[Symbol] + def ClassDefSymbol_fields(self: Symbol)(implicit ctx: Context): List[Symbol] /** Field with the given name directly declared in the class */ - def ClassSymbol_field(self: Symbol)(name: String)(implicit ctx: Context): Option[Symbol] + def ClassDefSymbol_field(self: Symbol)(name: String)(implicit ctx: Context): Option[Symbol] /** Get non-private named methods defined directly inside the class */ - def ClassSymbol_classMethod(self: Symbol)(name: String)(implicit ctx: Context): List[DefSymbol] + def ClassDefSymbol_classMethod(self: Symbol)(name: String)(implicit ctx: Context): List[DefDefSymbol] - /** Get all non-private methods defined directly inside the class, exluding constructors */ - def ClassSymbol_classMethods(self: Symbol)(implicit ctx: Context): List[DefSymbol] + /** Get all non-private methods defined directly inside the class, excluding constructors */ + def ClassDefSymbol_classMethods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] /** Get named non-private methods declared or inherited */ - def ClassSymbol_method(self: Symbol)(name: String)(implicit ctx: Context): List[DefSymbol] + def ClassDefSymbol_method(self: Symbol)(name: String)(implicit ctx: Context): List[DefDefSymbol] /** Get all non-private methods declared or inherited */ - def ClassSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefSymbol] + def ClassDefSymbol_methods(self: Symbol)(implicit ctx: Context): List[DefDefSymbol] /** Fields of a case class type -- only the ones declared in primary constructor */ - def ClassSymbol_caseFields(self: Symbol)(implicit ctx: Context): List[ValSymbol] + def ClassDefSymbol_caseFields(self: Symbol)(implicit ctx: Context): List[ValDefSymbol] /** The class symbol of the companion module class */ - def ClassSymbol_companionClass(self: Symbol)(implicit ctx: Context): Option[ClassSymbol] + def ClassDefSymbol_companionClass(self: Symbol)(implicit ctx: Context): Option[ClassDefSymbol] /** The symbol of the companion module */ - def ClassSymbol_companionModule(self: Symbol)(implicit ctx: Context): Option[ValSymbol] + def ClassDefSymbol_companionModule(self: Symbol)(implicit ctx: Context): Option[ValDefSymbol] /** The symbol of the class of the companion module */ - def ClassSymbol_moduleClass(self: Symbol)(implicit ctx: Context): Option[Symbol] + def ClassDefSymbol_moduleClass(self: Symbol)(implicit ctx: Context): Option[Symbol] - def ClassSymbol_of(fullName: String)(implicit ctx: Context): ClassSymbol + def ClassDefSymbol_of(fullName: String)(implicit ctx: Context): ClassDefSymbol /** Symbol of a type (parameter or member) definition. */ - type TypeSymbol <: Symbol + type TypeDefSymbol <: TypeSymbol - def matchTypeSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] + def matchTypeDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeDefSymbol] - def TypeSymbol_isTypeParam(self: TypeSymbol)(implicit ctx: Context): Boolean + def TypeDefSymbol_isTypeParam(self: TypeDefSymbol)(implicit ctx: Context): Boolean /** TypeDef tree of this definition */ - def TypeSymbol_tree(self: TypeSymbol)(implicit ctx: Context): TypeDef + def TypeDefSymbol_tree(self: TypeDefSymbol)(implicit ctx: Context): TypeDef + + /** Symbol representing a bind definition. */ + type TypeBindSymbol <: TypeSymbol + + def matchTypeBindSymbol(symbol: Symbol)(implicit ctx: Context): Option[TypeBindSymbol] + + /** TypeBind pattern of this definition */ + def TypeBindSymbol_tree(self: TypeBindSymbol)(implicit ctx: Context): TypeTree_TypeBind + + type TermSymbol <: Symbol + + def matchTermSymbol(symbol: Symbol)(implicit ctx: Context): Option[TermSymbol] /** Symbol representing a method definition. */ - type DefSymbol <: Symbol + type DefDefSymbol <: TermSymbol - def matchDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[DefSymbol] + def matchDefDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[DefDefSymbol] - /** DefDef tree of this defintion */ - def DefSymbol_tree(self: DefSymbol)(implicit ctx: Context): DefDef + /** DefDef tree of this definition */ + def DefDefSymbol_tree(self: DefDefSymbol)(implicit ctx: Context): DefDef - /** Signature of this defintion */ - def DefSymbol_signature(self: DefSymbol)(implicit ctx: Context): Signature + /** Signature of this definition */ + def DefDefSymbol_signature(self: DefDefSymbol)(implicit ctx: Context): Signature /** Symbol representing a value definition. This includes `val`, `lazy val`, `var`, `object` and parameter definitions. */ - type ValSymbol <: Symbol + type ValDefSymbol <: TermSymbol - def matchValSymbol(symbol: Symbol)(implicit ctx: Context): Option[ValSymbol] + def matchValDefSymbol(symbol: Symbol)(implicit ctx: Context): Option[ValDefSymbol] - /** ValDef tree of this defintion */ - def ValSymbol_tree(self: ValSymbol)(implicit ctx: Context): ValDef + /** ValDef tree of this definition */ + def ValDefSymbol_tree(self: ValDefSymbol)(implicit ctx: Context): ValDef /** The class symbol of the companion module class */ - def ValSymbol_moduleClass(self: ValSymbol)(implicit ctx: Context): Option[ClassSymbol] + def ValDefSymbol_moduleClass(self: ValDefSymbol)(implicit ctx: Context): Option[ClassDefSymbol] - def ValSymbol_companionClass(self: ValSymbol)(implicit ctx: Context): Option[ClassSymbol] + def ValDefSymbol_companionClass(self: ValDefSymbol)(implicit ctx: Context): Option[ClassDefSymbol] /** Symbol representing a bind definition. */ - type BindSymbol <: Symbol + type BindSymbol <: TermSymbol def matchBindSymbol(symbol: Symbol)(implicit ctx: Context): Option[BindSymbol] diff --git a/library/src/scala/tasty/reflect/Printers.scala b/library/src/scala/tasty/reflect/Printers.scala index 9fb20a1fce1c..81c5e3057e17 100644 --- a/library/src/scala/tasty/reflect/Printers.scala +++ b/library/src/scala/tasty/reflect/Printers.scala @@ -335,11 +335,11 @@ trait Printers } def visitSymbol(x: Symbol): Buffer = x match { - case IsPackageSymbol(x) => this += "IsPackageSymbol(<" += x.fullName += ">)" - case IsClassSymbol(x) => this += "IsClassSymbol(<" += x.fullName += ">)" - case IsDefSymbol(x) => this += "IsDefSymbol(<" += x.fullName += ">)" - case IsValSymbol(x) => this += "IsValSymbol(<" += x.fullName += ">)" - case IsTypeSymbol(x) => this += "IsTypeSymbol(<" += x.fullName += ">)" + case IsPackageDefSymbol(x) => this += "IsPackageDefSymbol(<" += x.fullName += ">)" + case IsClassDefSymbol(x) => this += "IsClassDefSymbol(<" += x.fullName += ">)" + case IsDefDefSymbol(x) => this += "IsDefDefSymbol(<" += x.fullName += ">)" + case IsValDefSymbol(x) => this += "IsValDefSymbol(<" += x.fullName += ">)" + case IsTypeDefSymbol(x) => this += "IsTypeDefSymbol(<" += x.fullName += ">)" case NoSymbol() => this += "NoSymbol()" } @@ -1225,8 +1225,8 @@ trait Printers def printParamDef(arg: ValDef): Unit = { val name = arg.name arg.symbol.owner match { - case IsDefSymbol(sym) if sym.name == "" => - val ClassDef(_, _, _, _, _, body) = sym.owner.asClass.tree + case IsDefDefSymbol(sym) if sym.name == "" => + val ClassDef(_, _, _, _, _, body) = sym.owner.asClassDef.tree body.collectFirst { case IsValDef(vdef @ ValDef(`name`, _, _)) if vdef.symbol.flags.is(Flags.ParamAccessor) => if (!vdef.symbol.flags.is(Flags.Local)) { @@ -1354,10 +1354,10 @@ trait Printers printTypeAndAnnots(tp) this += " " printAnnotation(annot) - case Type.SymRef(IsClassSymbol(sym), _) if sym.fullName == "scala.runtime.Null$" || sym.fullName == "scala.runtime.Nothing$" => + case Type.SymRef(IsClassDefSymbol(sym), _) if sym.fullName == "scala.runtime.Null$" || sym.fullName == "scala.runtime.Nothing$" => // scala.runtime.Null$ and scala.runtime.Nothing$ are not modules, those are their actual names printType(tpe) - case tpe @ Type.SymRef(IsClassSymbol(sym), _) if sym.name.endsWith("$") => + case tpe @ Type.SymRef(IsClassDefSymbol(sym), _) if sym.name.endsWith("$") => printType(tpe) this += ".type" case tpe => printType(tpe) @@ -1452,7 +1452,7 @@ trait Printers if (packagePath != "") this += packagePath += "." } - case IsType(prefix @ Type.SymRef(IsClassSymbol(_), _)) => + case IsType(prefix @ Type.SymRef(IsClassDefSymbol(_), _)) => printType(prefix) this += "#" case IsType(prefix) => @@ -1717,7 +1717,7 @@ trait Printers def printFullClassName(tp: TypeOrBounds): Unit = { def printClassPrefix(prefix: TypeOrBounds): Unit = prefix match { - case Type.SymRef(IsClassSymbol(sym), prefix2) => + case Type.SymRef(IsClassDefSymbol(sym), prefix2) => printClassPrefix(prefix2) this += sym.name += "." case _ => @@ -1756,7 +1756,7 @@ trait Printers def unapply(arg: Tree)(implicit ctx: Context): Option[(String, List[Term])] = arg match { case IsTerm(arg @ Term.Apply(fn, args)) => fn.tpe match { - case Type.SymRef(IsDefSymbol(sym), Type.ThisType(Type.SymRef(sym2, _))) if sym2.name == "" => + case Type.SymRef(IsDefDefSymbol(sym), Type.ThisType(Type.SymRef(sym2, _))) if sym2.name == "" => Some((sym.tree.name, args)) case _ => None } diff --git a/library/src/scala/tasty/reflect/SymbolOps.scala b/library/src/scala/tasty/reflect/SymbolOps.scala index 5848f22fe53a..5e34d610c4c8 100644 --- a/library/src/scala/tasty/reflect/SymbolOps.scala +++ b/library/src/scala/tasty/reflect/SymbolOps.scala @@ -34,38 +34,38 @@ trait SymbolOps extends Core { /** The comment for this symbol, if any */ def comment(implicit ctx: Context): Option[Comment] = kernel.Symbol_comment(self) - /** Unsafe cast as to PackageSymbol. Use IsPackageSymbol to safly check and cast to PackageSymbol */ - def asPackage(implicit ctx: Context): PackageSymbol = self match { - case IsPackageSymbol(self) => self - case _ => throw new Exception("not a PackageSymbol") + /** Unsafe cast as to PackageSymbol. Use IsPackageSymbol to safely check and cast to PackageSymbol */ + def asPackageDef(implicit ctx: Context): PackageDefSymbol = self match { + case IsPackageDefSymbol(self) => self + case _ => throw new Exception("not a PackageDefSymbol") } - /** Unsafe cast as to ClassSymbol. Use IsClassSymbol to safly check and cast to ClassSymbol */ - def asClass(implicit ctx: Context): ClassSymbol = self match { - case IsClassSymbol(self) => self - case _ => throw new Exception("not a ClassSymbol") + /** Unsafe cast as to ClassSymbol. Use IsClassDefSymbol to safely check and cast to ClassSymbol */ + def asClassDef(implicit ctx: Context): ClassDefSymbol = self match { + case IsClassDefSymbol(self) => self + case _ => throw new Exception("not a ClassDefSymbol") } - /** Unsafe cast as to DefSymbol. Use IsDefSymbol to safly check and cast to DefSymbol */ - def asDef(implicit ctx: Context): DefSymbol = self match { - case IsDefSymbol(self) => self - case _ => throw new Exception("not a DefSymbol") + /** Unsafe cast as to DefSymbol. Use IsDefDefSymbol to safely check and cast to DefSymbol */ + def asDefDef(implicit ctx: Context): DefDefSymbol = self match { + case IsDefDefSymbol(self) => self + case _ => throw new Exception("not a DefDefSymbol") } - /** Unsafe cast as to ValSymbol. Use IsValSymbol to safly check and cast to ValSymbol */ - def asVal(implicit ctx: Context): ValSymbol = self match { - case IsValSymbol(self) => self - case _ => throw new Exception("not a ValSymbol") + /** Unsafe cast as to ValSymbol. Use IsValDefSymbol to safely check and cast to ValSymbol */ + def asValDef(implicit ctx: Context): ValDefSymbol = self match { + case IsValDefSymbol(self) => self + case _ => throw new Exception("not a ValDefSymbol") } - /** Unsafe cast as to TypeSymbol. Use IsTypeSymbol to safly check and cast to TypeSymbol */ - def asType(implicit ctx: Context): TypeSymbol = self match { - case IsTypeSymbol(self) => self - case _ => throw new Exception("not a TypeSymbol") + /** Unsafe cast as to TypeSymbol. Use IsTypeDefSymbol to safely check and cast to TypeSymbol */ + def asTypeDef(implicit ctx: Context): TypeDefSymbol = self match { + case IsTypeDefSymbol(self) => self + case _ => throw new Exception("not a TypeDefSymbol") } - /** Unsafe cast as to BindSymbol. Use IsBindSymbol to safly check and cast to BindSymbol */ - def asBind(implicit ctx: Context): BindSymbol = self match { + /** Unsafe cast as to BindSymbol. Use IsBindSymbol to safely check and cast to BindSymbol */ + def asBindDef(implicit ctx: Context): BindSymbol = self match { case IsBindSymbol(self) => self case _ => throw new Exception("not a BindSymbol") } @@ -86,126 +86,153 @@ trait SymbolOps extends Core { // PackageSymbol - object IsPackageSymbol { - def unapply(symbol: Symbol)(implicit ctx: Context): Option[PackageSymbol] = - kernel.matchPackageSymbol(symbol) + object IsPackageDefSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[PackageDefSymbol] = + kernel.matchPackageDefSymbol(symbol) } - implicit class PackageSymbolAPI(self: PackageSymbol) { + implicit class PackageDefSymbolAPI(self: PackageDefSymbol) { def tree(implicit ctx: Context): PackageDef = - kernel.PackageSymbol_tree(self) + kernel.PackageDefSymbol_tree(self) + } + + // TypeSymbol + + object IsTypeSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] = + kernel.matchTypeSymbol(symbol) } // ClassSymbol - object IsClassSymbol { - def unapply(symbol: Symbol)(implicit ctx: Context): Option[ClassSymbol] = - kernel.matchClassSymbol(symbol) + object IsClassDefSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[ClassDefSymbol] = + kernel.matchClassDefSymbol(symbol) } - object ClassSymbol { + object ClassDefSymbol { /** The ClassSymbol of a global class definition */ - def of(fullName: String)(implicit ctx: Context): ClassSymbol = - kernel.ClassSymbol_of(fullName) + def of(fullName: String)(implicit ctx: Context): ClassDefSymbol = + kernel.ClassDefSymbol_of(fullName) } - implicit class ClassSymbolAPI(self: ClassSymbol) { + implicit class ClassDefSymbolAPI(self: ClassDefSymbol) { /** ClassDef tree of this defintion */ def tree(implicit ctx: Context): ClassDef = - kernel.ClassSymbol_tree(self) + kernel.ClassDefSymbol_tree(self) /** Fields directly declared in the class */ def fields(implicit ctx: Context): List[Symbol] = - kernel.ClassSymbol_fields(self) + kernel.ClassDefSymbol_fields(self) /** Field with the given name directly declared in the class */ def field(name: String)(implicit ctx: Context): Option[Symbol] = - kernel.ClassSymbol_field(self)(name) + kernel.ClassDefSymbol_field(self)(name) /** Get non-private named methods defined directly inside the class */ - def classMethod(name: String)(implicit ctx: Context): List[DefSymbol] = - kernel.ClassSymbol_classMethod(self)(name) + def classMethod(name: String)(implicit ctx: Context): List[DefDefSymbol] = + kernel.ClassDefSymbol_classMethod(self)(name) /** Get all non-private methods defined directly inside the class, exluding constructors */ - def classMethods(implicit ctx: Context): List[DefSymbol] = - kernel.ClassSymbol_classMethods(self) + def classMethods(implicit ctx: Context): List[DefDefSymbol] = + kernel.ClassDefSymbol_classMethods(self) /** Get named non-private methods declared or inherited */ - def method(name: String)(implicit ctx: Context): List[DefSymbol] = - kernel.ClassSymbol_method(self)(name) + def method(name: String)(implicit ctx: Context): List[DefDefSymbol] = + kernel.ClassDefSymbol_method(self)(name) /** Get all non-private methods declared or inherited */ - def methods(implicit ctx: Context): List[DefSymbol] = - kernel.ClassSymbol_methods(self) + def methods(implicit ctx: Context): List[DefDefSymbol] = + kernel.ClassDefSymbol_methods(self) /** Fields of a case class type -- only the ones declared in primary constructor */ - def caseFields(implicit ctx: Context): List[ValSymbol] = - kernel.ClassSymbol_caseFields(self) + def caseFields(implicit ctx: Context): List[ValDefSymbol] = + kernel.ClassDefSymbol_caseFields(self) /** The class symbol of the companion module class */ - def companionClass(implicit ctx: Context): Option[ClassSymbol] = - kernel.ClassSymbol_companionClass(self) + def companionClass(implicit ctx: Context): Option[ClassDefSymbol] = + kernel.ClassDefSymbol_companionClass(self) /** The symbol of the companion module */ - def companionModule(implicit ctx: Context): Option[ValSymbol] = - kernel.ClassSymbol_companionModule(self) + def companionModule(implicit ctx: Context): Option[ValDefSymbol] = + kernel.ClassDefSymbol_companionModule(self) /** The symbol of the class of the companion module */ def moduleClass(implicit ctx: Context): Option[Symbol] = - kernel.ClassSymbol_moduleClass(self) + kernel.ClassDefSymbol_moduleClass(self) } // TypeSymbol - object IsTypeSymbol { - def unapply(symbol: Symbol)(implicit ctx: Context): Option[TypeSymbol] = - kernel.matchTypeSymbol(symbol) + object IsTypeDefSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[TypeDefSymbol] = + kernel.matchTypeDefSymbol(symbol) } - implicit class TypeSymbolAPI(self: TypeSymbol) { + implicit class TypeDefSymbolAPI(self: TypeDefSymbol) { /** TypeDef tree of this definition */ def tree(implicit ctx: Context): TypeDef = - kernel.TypeSymbol_tree(self) + kernel.TypeDefSymbol_tree(self) def isTypeParam(implicit ctx: Context): Boolean = - kernel.TypeSymbol_isTypeParam(self) + kernel.TypeDefSymbol_isTypeParam(self) + } + + // TypeBindSymbol + + object IsTypeBindSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[TypeBindSymbol] = + kernel.matchTypeBindSymbol(symbol) + } + + implicit class TypeBindSymbolAPI(self: TypeBindSymbol) { + /** TypeBind pattern of this definition */ + def tree(implicit ctx: Context): TypeTree.TypeBind = + kernel.TypeBindSymbol_tree(self) + } + + // TermSymbol + + object IsTermSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[TermSymbol] = + kernel.matchTermSymbol(symbol) } // DefSymbol - object IsDefSymbol { - def unapply(symbol: Symbol)(implicit ctx: Context): Option[DefSymbol] = - kernel.matchDefSymbol(symbol) + object IsDefDefSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[DefDefSymbol] = + kernel.matchDefDefSymbol(symbol) } - implicit class DefSymbolAPI(self: DefSymbol) { + implicit class DefDefSymbolAPI(self: DefDefSymbol) { /** DefDef tree of this defintion */ def tree(implicit ctx: Context): DefDef = - kernel.DefSymbol_tree(self) + kernel.DefDefSymbol_tree(self) /** Signature of this defintion */ def signature(implicit ctx: Context): Signature = - kernel.DefSymbol_signature(self) + kernel.DefDefSymbol_signature(self) } // ValSymbol - object IsValSymbol { - def unapply(symbol: Symbol)(implicit ctx: Context): Option[ValSymbol] = - kernel.matchValSymbol(symbol) + object IsValDefSymbol { + def unapply(symbol: Symbol)(implicit ctx: Context): Option[ValDefSymbol] = + kernel.matchValDefSymbol(symbol) } - implicit class ValSymbolAPI(self: ValSymbol) { + implicit class ValDefSymbolAPI(self: ValDefSymbol) { /** ValDef tree of this defintion */ def tree(implicit ctx: Context): ValDef = - kernel.ValSymbol_tree(self) + kernel.ValDefSymbol_tree(self) /** The class symbol of the companion module class */ - def moduleClass(implicit ctx: Context): Option[ClassSymbol] = - kernel.ValSymbol_moduleClass(self) + def moduleClass(implicit ctx: Context): Option[ClassDefSymbol] = + kernel.ValDefSymbol_moduleClass(self) - def companionClass(implicit ctx: Context): Option[ClassSymbol] = - kernel.ValSymbol_companionClass(self) + def companionClass(implicit ctx: Context): Option[ClassDefSymbol] = + kernel.ValDefSymbol_companionClass(self) } // BindSymbol diff --git a/library/src/scala/tasty/reflect/TreeOps.scala b/library/src/scala/tasty/reflect/TreeOps.scala index 2c456949d777..4175892a4e2a 100644 --- a/library/src/scala/tasty/reflect/TreeOps.scala +++ b/library/src/scala/tasty/reflect/TreeOps.scala @@ -87,7 +87,7 @@ trait TreeOps extends Core { def derived(implicit ctx: Context): List[TypeTree] = kernel.ClassDef_derived(self) def self(implicit ctx: Context): Option[ValDef] = kernel.ClassDef_self(self) def body(implicit ctx: Context): List[Statement] = kernel.ClassDef_body(self) - def symbol(implicit ctx: Context): ClassSymbol = kernel.ClassDef_symbol(self) + def symbol(implicit ctx: Context): ClassDefSymbol = kernel.ClassDef_symbol(self) } // DefDef @@ -97,7 +97,7 @@ trait TreeOps extends Core { } object DefDef { - def apply(symbol: DefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef = + def apply(symbol: DefDefSymbol, rhsFn: List[Type] => List[List[Term]] => Option[Term])(implicit ctx: Context): DefDef = kernel.DefDef_apply(symbol, rhsFn) def copy(original: DefDef)(name: String, typeParams: List[TypeDef], paramss: List[List[ValDef]], tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): DefDef = kernel.DefDef_copy(original)(name, typeParams, paramss, tpt, rhs) @@ -110,7 +110,7 @@ trait TreeOps extends Core { def paramss(implicit ctx: Context): List[List[ValDef]] = kernel.DefDef_paramss(self) def returnTpt(implicit ctx: Context): TypeTree = kernel.DefDef_returnTpt(self) // TODO rename to tpt def rhs(implicit ctx: Context): Option[Term] = kernel.DefDef_rhs(self) - def symbol(implicit ctx: Context): DefSymbol = kernel.DefDef_symbol(self) + def symbol(implicit ctx: Context): DefDefSymbol = kernel.DefDef_symbol(self) } // ValDef @@ -120,7 +120,7 @@ trait TreeOps extends Core { } object ValDef { - def apply(symbol: ValSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef = + def apply(symbol: ValDefSymbol, rhs: Option[Term])(implicit ctx: Context): ValDef = kernel.ValDef_apply(symbol, rhs) def copy(original: ValDef)(name: String, tpt: TypeTree, rhs: Option[Term])(implicit ctx: Context): ValDef = kernel.ValDef_copy(original)(name, tpt, rhs) @@ -131,7 +131,7 @@ trait TreeOps extends Core { implicit class ValDefAPI(self: ValDef) { def tpt(implicit ctx: Context): TypeTree = kernel.ValDef_tpt(self) def rhs(implicit ctx: Context): Option[Term] = kernel.ValDef_rhs(self) - def symbol(implicit ctx: Context): ValSymbol = kernel.ValDef_symbol(self) + def symbol(implicit ctx: Context): ValDefSymbol = kernel.ValDef_symbol(self) } // TypeDef @@ -141,7 +141,7 @@ trait TreeOps extends Core { } object TypeDef { - def apply(symbol: TypeSymbol)(implicit ctx: Context): TypeDef = + def apply(symbol: TypeDefSymbol)(implicit ctx: Context): TypeDef = kernel.TypeDef_apply(symbol) def copy(original: TypeDef)(name: String, rhs: Tree /*TypeTree | TypeBoundsTree*/)(implicit ctx: Context): TypeDef = kernel.TypeDef_copy(original)(name, rhs) @@ -151,7 +151,7 @@ trait TreeOps extends Core { implicit class TypeDefAPI(self: TypeDef) { def rhs(implicit ctx: Context): Tree /*TypeTree | TypeBoundsTree*/ = kernel.TypeDef_rhs(self) - def symbol(implicit ctx: Context): TypeSymbol = kernel.TypeDef_symbol(self) + def symbol(implicit ctx: Context): TypeDefSymbol = kernel.TypeDef_symbol(self) } // PackageDef @@ -164,7 +164,7 @@ trait TreeOps extends Core { implicit class PackageDefAPI(self: PackageDef) { def owner(implicit ctx: Context): PackageDef = kernel.PackageDef_owner(self) def members(implicit ctx: Context): List[Statement] = kernel.PackageDef_members(self) - def symbol(implicit ctx: Context): PackageSymbol = kernel.PackageDef_symbol(self) + def symbol(implicit ctx: Context): PackageDefSymbol = kernel.PackageDef_symbol(self) } object PackageDef { @@ -276,7 +276,7 @@ trait TreeOps extends Core { object This { /** Create a `this[` */ - def apply(cls: ClassSymbol)(implicit ctx: Context): This = + def apply(cls: ClassDefSymbol)(implicit ctx: Context): This = kernel.This_apply(cls) def copy(original: Tree)(qual: Option[Id])(implicit ctx: Context): This = diff --git a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala index b8dec49d7b7f..1a6f162e89ba 100644 --- a/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala +++ b/library/src/scala/tasty/reflect/TypeOrBoundsOps.scala @@ -18,7 +18,7 @@ trait TypeOrBoundsOps extends Core { */ def dealias(implicit ctx: Context): Type = kernel.Type_dealias(self) - def classSymbol(implicit ctx: Context): Option[ClassSymbol] = kernel.Type_classSymbol(self) + def classSymbol(implicit ctx: Context): Option[ClassDefSymbol] = kernel.Type_classSymbol(self) def typeSymbol(implicit ctx: Context): Symbol = kernel.Type_typeSymbol(self) def isSingleton(implicit ctx: Context): Boolean = kernel.Type_isSingleton(self) def memberType(member: Symbol)(implicit ctx: Context): Type = kernel.Type_memberType(self)(member) diff --git a/semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala b/semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala index 8bf7e2f39365..9535e3ef408c 100644 --- a/semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala +++ b/semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala @@ -134,31 +134,31 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum def isClass: Boolean = symbol match { - case IsClassSymbol(_) => true + case IsClassDefSymbol(_) => true case _ => false } def isTypeParameter: Boolean = symbol.isParameter && symbol.isType def isType: Boolean = symbol match { - case IsTypeSymbol(_) => true + case IsTypeDefSymbol(_) => true case _ => false } def isTerm: Boolean = !symbol.isType def isMethod: Boolean = symbol match { - case IsDefSymbol(_) => true + case IsDefDefSymbol(_) => true case _ => false } def isVal: Boolean = symbol match { - case IsValSymbol(_) => true + case IsValDefSymbol(_) => true case _ => false } def isPackage: Boolean = symbol match { - case IsPackageSymbol(_) => true + case IsPackageDefSymbol(_) => true case _ => false } @@ -259,12 +259,12 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum def isSyntheticValueClassCompanion(implicit ctx: Context): Boolean = { if (symbol.isClass) { if (symbol.flags.is(Flags.Object)) { - symbol.asClass.moduleClass.fold(false)(c => + symbol.asClassDef.moduleClass.fold(false)(c => c.isSyntheticValueClassCompanion) } else { symbol.flags.is(Flags.ModuleClass) && symbol.flags.is(Flags.Synthetic) && - symbol.asClass.methods.isEmpty + symbol.asClassDef.methods.isEmpty } } else { false @@ -292,7 +292,7 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum } def isSyntheticJavaModule(implicit ctx: Context): Boolean = { val resolved = symbol match { - case IsClassSymbol(c) => resolveClass(c) + case IsClassDefSymbol(c) => resolveClass(c) case _ => symbol } !resolved.flags.is(Flags.Package) && resolved.flags.is(Flags.JavaDefined) && resolved.flags.is(Flags.Object) @@ -350,7 +350,7 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum } } - def resolveClass(symbol: ClassSymbol): Symbol = + def resolveClass(symbol: ClassDefSymbol): Symbol = (symbol.companionClass, symbol.companionModule) match { case (Some(c), _) => c case (_, Some(module)) if symbol.flags.is(Flags.Object) => module @@ -359,9 +359,9 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum def disimbiguate(symbolPath: String, symbol: Symbol): String = { try { - val symbolcl = resolveClass(symbol.owner.asClass) + val symbolcl = resolveClass(symbol.owner.asClassDef) symbolcl match { - case IsClassSymbol(classsymbol) => { + case IsClassDefSymbol(classsymbol) => { val methods = classsymbol.method(symbol.name) val (methods_count, method_pos) = methods.foldLeft((0, -1))((x: Tuple2[Int, Int], m: Symbol) => { @@ -392,7 +392,7 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum "" } else { val rsymbol = symbol match { - case IsClassSymbol(c) => resolveClass(c) + case IsClassDefSymbol(c) => resolveClass(c) case _ => symbol } val previous_symbol = @@ -406,7 +406,7 @@ class SemanticdbConsumer(sourceFilePath: java.nio.file.Path) extends TastyConsum iterateParent(rsymbol.owner) - val isdef = rsymbol match {case IsDefSymbol(_) => true case _ => false} + val isdef = rsymbol match {case IsDefDefSymbol(_) => true case _ => false} val symbolName = if (isMutableAssignement) rsymbol.trueName + "_=" else rsymbol.trueName val next_atom = if (rsymbol.isPackage) { diff --git a/tests/neg/tasty-macro-assert-1/quoted_1.scala b/tests/neg/tasty-macro-assert-1/quoted_1.scala index 801219e3e78b..b52a238bd41b 100644 --- a/tests/neg/tasty-macro-assert-1/quoted_1.scala +++ b/tests/neg/tasty-macro-assert-1/quoted_1.scala @@ -20,7 +20,7 @@ object Asserts { val tree = cond.unseal def isOps(tpe: TypeOrBounds): Boolean = tpe match { - case Type.SymRef(IsDefSymbol(sym), _) => sym.name == "Ops" // TODO check that the parent is Asserts + case Type.SymRef(IsDefDefSymbol(sym), _) => sym.name == "Ops" // TODO check that the parent is Asserts case _ => false } diff --git a/tests/neg/tasty-macro-assert-2/quoted_1.scala b/tests/neg/tasty-macro-assert-2/quoted_1.scala index f3796a7a31f4..34afc5800a0f 100644 --- a/tests/neg/tasty-macro-assert-2/quoted_1.scala +++ b/tests/neg/tasty-macro-assert-2/quoted_1.scala @@ -20,7 +20,7 @@ object Asserts { val tree = cond.unseal def isOps(tpe: TypeOrBounds): Boolean = tpe match { - case Type.SymRef(IsDefSymbol(sym), _) => sym.name == "Ops" // TODO check that the parent is Asserts + case Type.SymRef(IsDefDefSymbol(sym), _) => sym.name == "Ops" // TODO check that the parent is Asserts case _ => false } diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala index f3c519c1490f..1c03f7351e2c 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-2/Macro_1.scala @@ -9,8 +9,8 @@ object Foo { def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsDefSymbol(sym) => sym.tree.show.toExpr - case IsValSymbol(sym) => sym.tree.show.toExpr + case IsDefDefSymbol(sym) => sym.tree.show.toExpr + case IsValDefSymbol(sym) => sym.tree.show.toExpr case IsBindSymbol(sym) => sym.tree.show.toExpr } x.unseal match { diff --git a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala index a491db7ae672..c667717d07a2 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-definitions-3/Macro_1.scala @@ -9,8 +9,8 @@ object Foo { def inspectBodyImpl(x: Expr[Int])(implicit reflect: Reflection): Expr[String] = { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsDefSymbol(sym) => sym.tree.show.toExpr - case IsValSymbol(sym) => sym.tree.show.toExpr + case IsDefDefSymbol(sym) => sym.tree.show.toExpr + case IsValDefSymbol(sym) => sym.tree.show.toExpr case IsBindSymbol(sym) => sym.tree.show.toExpr } x.unseal match { diff --git a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala index 8825ed30d64c..17b58d0d135d 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_1.scala @@ -14,9 +14,9 @@ object Macros { implicit class SymOps(sym: Symbol) { def treeOpt: Option[Tree] = sym match { - case IsClassSymbol(sym) => Some(sym.tree) - case IsDefSymbol(sym) => Some(sym.tree) - case IsValSymbol(sym) => Some(sym.tree) + case IsClassDefSymbol(sym) => Some(sym.tree) + case IsDefDefSymbol(sym) => Some(sym.tree) + case IsValDefSymbol(sym) => Some(sym.tree) case _ => None } } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala index d286b1d30bdc..2bb11a418d83 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_1.scala @@ -11,9 +11,9 @@ object Foo { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassSymbol(sym) => sym.tree.show.toExpr - case IsDefSymbol(sym) => sym.tree.show.toExpr - case IsValSymbol(sym) => sym.tree.show.toExpr + case IsClassDefSymbol(sym) => sym.tree.show.toExpr + case IsDefDefSymbol(sym) => sym.tree.show.toExpr + case IsValDefSymbol(sym) => sym.tree.show.toExpr case _ => '{"NO DEFINTION"} } diff --git a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala index 6c7c985c935f..1047d81a75ef 100644 --- a/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala +++ b/tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_1.scala @@ -11,9 +11,9 @@ object Foo { import reflect._ def definitionString(tree: Tree): Expr[String] = tree.symbol match { - case IsClassSymbol(sym) => sym.tree.show.toExpr - case IsDefSymbol(sym) => sym.tree.show.toExpr - case IsValSymbol(sym) => sym.tree.show.toExpr + case IsClassDefSymbol(sym) => sym.tree.show.toExpr + case IsDefDefSymbol(sym) => sym.tree.show.toExpr + case IsValDefSymbol(sym) => sym.tree.show.toExpr case _ => '{"NO DEFINTION"} } diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala index bd96c338677a..3a737a9fdb5c 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala @@ -23,7 +23,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: given Env => T)(implicit env: Env): T = in given (env ++ syms.zip(values)) - def interpretCall(inst: AbstractAny, sym: DefSymbol, args: List[AbstractAny]): Result = { + def interpretCall(inst: AbstractAny, sym: DefDefSymbol, args: List[AbstractAny]): Result = { // TODO // withLocalValue(`this`, inst) { val syms = sym.tree.paramss.headOption.getOrElse(Nil).map(_.symbol) @@ -41,7 +41,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { case _ => } val evaluatedArgs = argss.flatten.map(arg => LocalValue.valFrom(eval(arg))) - val IsDefSymbol(sym) = fn.symbol + val IsDefDefSymbol(sym) = fn.symbol val syms = sym.tree.paramss.headOption.getOrElse(Nil).map(_.symbol) withLocalValues(syms, evaluatedArgs) { eval(sym.tree.rhs.get) @@ -134,7 +134,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) { log("interpretPrivitiveDiv", tree)(interpretPrivitiveDiv(lhs, rhs)) case _ => fn.symbol match { - case IsDefSymbol(sym) => log("interpretCall", tree)(interpretCall(fn, argss)) + case IsDefDefSymbol(sym) => log("interpretCall", tree)(interpretCall(fn, argss)) case _ => assert(argss.isEmpty) log("interpretValGet", tree)(interpretValGet(fn)) diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala index e27e00d14c65..5a974fe1b0e6 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala @@ -16,7 +16,7 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre if (fn.symbol.isDefinedInCurrentRun) { // Best effort to try to create a proxy fn.symbol.owner match { - case IsClassSymbol(sym) => + case IsClassDefSymbol(sym) => val parentSymbols = sym.tree.parents.tail.map(_.asInstanceOf[TypeTree].symbol).head import java.lang.reflect._ val handler: InvocationHandler = new InvocationHandler() { @@ -33,7 +33,7 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre if (symbol.isDefinedInCurrentRun) { val argsList = if (args == null) Nil else args.toList symbol match { - case IsDefSymbol(symbol) => + case IsDefDefSymbol(symbol) => interpretCall(this, symbol, argsList).asInstanceOf[Object] } } @@ -56,12 +56,12 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre else { fn match { case Term.Select(prefix, _) => - val IsDefSymbol(sym) = fn.symbol + val IsDefDefSymbol(sym) = fn.symbol val pre = eval(prefix).asInstanceOf[Object] val argss2 = evaluatedArgss(argss) jvmReflection.interpretMethodCall(pre, fn.symbol, argss2) case _ => - val IsDefSymbol(sym) = fn.symbol + val IsDefDefSymbol(sym) = fn.symbol val argss2 = evaluatedArgss(argss) jvmReflection.interpretStaticMethodCall(fn.symbol.owner, fn.symbol, argss2) } @@ -78,7 +78,7 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre jvmReflection.interpretStaticVal(fn.symbol.owner, fn.symbol) case _ => if (fn.symbol.flags.is(Flags.Object)) - jvmReflection.loadModule(fn.symbol.asVal.moduleClass.get) + jvmReflection.loadModule(fn.symbol.asValDef.moduleClass.get) else jvmReflection.interpretStaticVal(fn.symbol.owner, fn.symbol) } diff --git a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala index a18d76ea208f..f903955e7a57 100644 --- a/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala +++ b/tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala @@ -13,7 +13,7 @@ class JVMReflection[R <: Reflection & Singleton](val reflect: R) { def loadModule(sym: Symbol): Object = { sym.owner match { - case IsPackageSymbol(_) => + case IsPackageDefSymbol(_) => val moduleClass = getClassOf(sym) moduleClass.getField(MODULE_INSTANCE_FIELD).get(null) case _ => @@ -81,7 +81,7 @@ class JVMReflection[R <: Reflection & Singleton](val reflect: R) { } private def paramsSig(sym: Symbol): List[Class[_]] = { - sym.asDef.signature.paramSigs.map { param => + sym.asDefDef.signature.paramSigs.map { param => def javaArraySig(name: String): String = { if (name.endsWith("[]")) "[" + javaArraySig(name.dropRight(2)) else name match { diff --git a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala index b66e6b987a3d..52d5011e4fe6 100644 --- a/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala +++ b/tests/run/gestalt-type-toolbox-reflect/Macro_1.scala @@ -34,7 +34,7 @@ object TypeToolbox { private def isCaseClassImpl(tp: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ val res = tp.unseal.symbol match { - case IsClassSymbol(sym) => sym.flags.is(Flags.Case) + case IsClassDefSymbol(sym) => sym.flags.is(Flags.Case) case _ => false } res.toExpr @@ -44,46 +44,46 @@ object TypeToolbox { inline def caseFields[T]: List[String] = ${caseFieldsImpl('[T])} private def caseFieldsImpl(tp: Type[_])(implicit reflect: Reflection): Expr[List[String]] = { import reflect._ - val fields = tp.unseal.symbol.asClass.caseFields.map(_.name) + val fields = tp.unseal.symbol.asClassDef.caseFields.map(_.name) fields.toExpr } inline def fieldIn[T](inline mem: String): String = ${fieldInImpl('[T], mem)} private def fieldInImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[String] = { import reflect._ - val field = t.unseal.symbol.asClass.field(mem) + val field = t.unseal.symbol.asClassDef.field(mem) field.map(_.name).getOrElse("").toExpr } inline def fieldsIn[T]: Seq[String] = ${fieldsInImpl('[T])} private def fieldsInImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ - val fields = t.unseal.symbol.asClass.fields + val fields = t.unseal.symbol.asClassDef.fields fields.map(_.name).toList.toExpr } inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl('[T], mem)} private def methodInImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ - t.unseal.symbol.asClass.classMethod(mem).map(_.name).toExpr + t.unseal.symbol.asClassDef.classMethod(mem).map(_.name).toExpr } inline def methodsIn[T]: Seq[String] = ${methodsInImpl('[T])} private def methodsInImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ - t.unseal.symbol.asClass.classMethods.map(_.name).toExpr + t.unseal.symbol.asClassDef.classMethods.map(_.name).toExpr } inline def method[T](inline mem: String): Seq[String] = ${methodImpl('[T], mem)} private def methodImpl(t: Type[_], mem: String)(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ - t.unseal.symbol.asClass.method(mem).map(_.name).toExpr + t.unseal.symbol.asClassDef.method(mem).map(_.name).toExpr } inline def methods[T]: Seq[String] = ${methodsImpl('[T])} private def methodsImpl(t: Type[_])(implicit reflect: Reflection): Expr[Seq[String]] = { import reflect._ - t.unseal.symbol.asClass.methods.map(_.name).toExpr + t.unseal.symbol.asClassDef.methods.map(_.name).toExpr } inline def typeTag[T](x: T): String = ${typeTagImpl('[T])} @@ -96,7 +96,7 @@ object TypeToolbox { inline def companion[T1, T2]: Boolean = ${companionImpl('[T1], '[T2])} private def companionImpl(t1: Type[_], t2: Type[_])(implicit reflect: Reflection): Expr[Boolean] = { import reflect._ - val res = t1.unseal.symbol.asClass.companionModule.contains(t2.unseal.symbol) + val res = t1.unseal.symbol.asClassDef.companionModule.contains(t2.unseal.symbol) res.toExpr } @@ -104,8 +104,8 @@ object TypeToolbox { private def companionNameImpl(tp: Type[_])(implicit reflect: Reflection): Expr[String] = { import reflect._ val companionClassOpt = tp.unseal.symbol match { - case IsClassSymbol(sym) => sym.companionClass - case IsValSymbol(sym) => sym.companionClass + case IsClassDefSymbol(sym) => sym.companionClass + case IsValDefSymbol(sym) => sym.companionClass case _ => None } companionClassOpt.map(_.fullName).getOrElse("").toExpr diff --git a/tests/run/tasty-definitions-1.check b/tests/run/tasty-definitions-1.check index 88e8f9f8aa2b..8b500e5872ed 100644 --- a/tests/run/tasty-definitions-1.check +++ b/tests/run/tasty-definitions-1.check @@ -155,18 +155,18 @@ Tuple21 Tuple22 List(Unit, Boolean, Byte, Short, Int, Long, Float, Double, Char) List(Byte, Short, Int, Long, Float, Double, Char) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsTypeSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsTypeDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) diff --git a/tests/run/tasty-eval/quoted_1.scala b/tests/run/tasty-eval/quoted_1.scala index e423ec4fdadd..36b97414ae07 100644 --- a/tests/run/tasty-eval/quoted_1.scala +++ b/tests/run/tasty-eval/quoted_1.scala @@ -22,7 +22,7 @@ object Macros { import reflect._ e.unseal.tpe match { - case Type.SymRef(IsValSymbol(sym), pre) => + case Type.SymRef(IsValDefSymbol(sym), pre) => sym.tree.tpt.tpe match { case Type.ConstantType(Constant.Int(i)) => Some(i) case _ => None diff --git a/tests/run/tasty-extractors-1.check b/tests/run/tasty-extractors-1.check index bc4db2f21ce5..36ddc8f2f20e 100644 --- a/tests/run/tasty-extractors-1.check +++ b/tests/run/tasty-extractors-1.check @@ -17,16 +17,16 @@ Term.Inlined(None, Nil, Term.Literal(Constant.String("abc"))) Type.ConstantType(Constant.String("abc")) Term.Inlined(None, Nil, Term.Apply(Term.Ident("println"), List(Term.Literal(Constant.String("abc"))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Int(8)), TypeTree.Ident("Int"))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Byte(8)), TypeTree.Ident("Byte"))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Short(8)), TypeTree.Ident("Short"))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Literal(Constant.Char(a))) Type.ConstantType(Constant.Char(a)) @@ -35,86 +35,86 @@ Term.Inlined(None, Nil, Term.Block(List(Term.Literal(Constant.Int(1)), Term.Lite Type.ConstantType(Constant.Int(3)) Term.Inlined(None, Nil, Term.If(Term.Typed(Term.Literal(Constant.Boolean(true)), TypeTree.Ident("Boolean")), Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2)))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("a")), List(CaseDef(Pattern.Value(Term.Literal(Constant.String("a"))), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("b")), List(CaseDef(Pattern.Bind("n", Pattern.Value(Term.Ident("_"))), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("c")), List(CaseDef(Pattern.Bind("n", Pattern.TypeTest(TypeTree.Ident("String"))), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("e")), List(CaseDef(Pattern.Value(Term.Ident("_")), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("f")), List(CaseDef(Pattern.TypeTest(TypeTree.Ident("String")), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Typed(Term.Literal(Constant.String("g")), TypeTree.Ident("Any")), List(CaseDef(Pattern.Alternative(List(Pattern.TypeTest(TypeTree.Ident("String")), Pattern.TypeTest(TypeTree.Ident("Int")))), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Literal(Constant.String("h")), List(CaseDef(Pattern.Value(Term.Ident("_")), Some(Term.Literal(Constant.Boolean(false))), Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ValDef("a", TypeTree.Inferred(), Some(Term.Literal(Constant.String("o"))))), Term.Match(Term.Literal(Constant.String("i")), List(CaseDef(Pattern.Bind("a", Pattern.Value(Term.Ident("_"))), None, Term.Block(Nil, Term.Literal(Constant.Unit()))))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Match(Term.Ident("Nil"), List(CaseDef(Pattern.Unapply(Term.TypeApply(Term.Select(Term.Ident("List"), "unapplySeq"), List(TypeTree.Inferred())), Nil, List(Pattern.Bind("a", Pattern.Value(Term.Ident("_"))), Pattern.Bind("b", Pattern.Value(Term.Ident("_"))), Pattern.Bind("c", Pattern.Value(Term.Ident("_"))))), None, Term.Block(Nil, Term.Literal(Constant.Unit())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Try(Term.Literal(Constant.Int(1)), List(CaseDef(Pattern.Value(Term.Ident("_")), None, Term.Block(Nil, Term.Literal(Constant.Unit())))), None)) -Type.OrType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +Type.OrType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) Term.Inlined(None, Nil, Term.Try(Term.Literal(Constant.Int(2)), Nil, Some(Term.Literal(Constant.Unit())))) Type.ConstantType(Constant.Int(2)) Term.Inlined(None, Nil, Term.Try(Term.Literal(Constant.Int(3)), List(CaseDef(Pattern.Value(Term.Ident("_")), None, Term.Block(Nil, Term.Literal(Constant.Unit())))), Some(Term.Literal(Constant.Unit())))) -Type.OrType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +Type.OrType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) Term.Inlined(None, Nil, Term.Apply(Term.Select(Term.Literal(Constant.String("a")), "=="), List(Term.Literal(Constant.String("b"))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Apply(Term.Select(Term.New(TypeTree.Ident("Object")), ""), Nil)) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Apply(Term.Select(Term.Ident("Int"), "box"), List(Term.NamedArg("x", Term.Literal(Constant.Int(9)))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Apply(Term.TypeApply(Term.Select(Term.Ident("Ordering"), "apply"), List(TypeTree.Ident("Int"))), List(Term.Ident("Int")))) -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))))) Term.Inlined(None, Nil, Term.Block(List(ValDef("a", TypeTree.Ident("Int"), Some(Term.Literal(Constant.Int(3))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ValDef("b", TypeTree.Ident("Int"), Some(Term.Literal(Constant.Int(3))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f1", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Literal(Constant.Int(3))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f2", Nil, Nil, TypeTree.Ident("Int"), Some(Term.Return(Term.Literal(Constant.Int(4)))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f3", Nil, List(List(ValDef("i", TypeTree.Ident("Int"), None))), TypeTree.Ident("Int"), Some(Term.Ident("i")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f4", Nil, List(List(ValDef("i", TypeTree.Ident("Int"), None)), List(ValDef("j", TypeTree.Ident("Int"), None))), TypeTree.Ident("Int"), Some(Term.Apply(Term.Select(Term.Ident("i"), "+"), List(Term.Ident("j")))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f5", Nil, List(List(ValDef("i", TypeTree.Ident("Int"), None))), TypeTree.Ident("Int"), Some(Term.Ident("i"))), DefDef("f5$default$1", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(9))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f6", List(TypeDef("T", TypeBoundsTree(TypeTree.Inferred(), TypeTree.Inferred()))), List(List(ValDef("x", TypeTree.Ident("T"), None))), TypeTree.Ident("T"), Some(Term.Ident("x")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f7", List(TypeDef("T", TypeBoundsTree(TypeTree.Inferred(), TypeTree.Inferred()))), List(List(ValDef("x", TypeTree.Ident("T"), None))), TypeTree.Singleton(Term.Ident("x")), Some(Term.Ident("x")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f8", Nil, List(List(ValDef("i", TypeTree.Annotated(TypeTree.Applied(TypeTree.Inferred(), List(TypeTree.Ident("Int"))), Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), None))), TypeTree.Ident("Int"), Some(Term.Literal(Constant.Int(9))))), Term.Apply(Term.Ident("f8"), List(Term.Typed(Term.Repeated(List(Term.Literal(Constant.Int(1)), Term.Literal(Constant.Int(2)), Term.Literal(Constant.Int(3))), TypeTree.Inferred()), TypeTree.Inferred()))))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Block(List(DefDef("f9", Nil, List(List(ValDef("i", TypeTree.ByName(TypeTree.Ident("Int")), None))), TypeTree.Ident("Int"), Some(Term.Ident("i")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) diff --git a/tests/run/tasty-extractors-2.check b/tests/run/tasty-extractors-2.check index 9cfe4460e1ff..7dcbd9fbae84 100644 --- a/tests/run/tasty-extractors-2.check +++ b/tests/run/tasty-extractors-2.check @@ -1,105 +1,105 @@ Term.Inlined(None, Nil, Term.Block(List(ValDef("x", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(1))))), Term.Assign(Term.Ident("x"), Term.Literal(Constant.Int(2))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), Some(Term.Ident("x")))), Term.Lambda(Term.Ident("$anonfun"), None))) -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))), Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))), Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))))) Term.Inlined(None, Nil, Term.Ident("???")) -Type.SymRef(IsDefSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +Type.SymRef(IsDefDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) Term.Inlined(None, Nil, Term.Literal(Constant.Int(1))) Type.ConstantType(Constant.Int(1)) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Int(1)), TypeTree.Ident("Int"))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Typed(Term.Ident("Nil"), TypeTree.Applied(TypeTree.Ident("List"), List(TypeTree.Ident("Int"))))) -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))))) Term.Inlined(None, Nil, Term.Typed(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Baz")), ""), Nil), TypeTree.Applied(TypeTree.Ident("&"), List(TypeTree.Ident("Foo"), TypeTree.Ident("Bar"))))) -Type.AndType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix()))), Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.AndType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix()))), Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) Term.Inlined(None, Nil, Term.Typed(Term.Literal(Constant.Int(1)), TypeTree.Applied(TypeTree.Ident("|"), List(TypeTree.Ident("Int"), TypeTree.Ident("String"))))) -Type.OrType(Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))), Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))))) +Type.OrType(Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))), Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, Nil)), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ValDef("Foo", TypeTree.Ident("Foo$"), Some(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Serializable")), Nil, Some(ValDef("_", TypeTree.Singleton(Term.Ident("Foo")), None)), Nil)), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(TypeDef("Foo", TypeBoundsTree(TypeTree.Inferred(), TypeTree.Inferred()))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(TypeDef("Foo", TypeTree.Ident("Int"))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(TypeDef("Foo", TypeBoundsTree(TypeTree.Ident("Null"), TypeTree.Ident("Object")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(0)))), DefDef("a_=", Nil, List(List(ValDef("x$1", TypeTree.Inferred(), None))), TypeTree.Inferred(), Some(Term.Literal(Constant.Unit())))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(0))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(0))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(DefDef("a", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(0))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Product"), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Serializable")), Nil, None, List(DefDef("productElementName", Nil, List(List(ValDef("x$1", TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Int"), None))), TypeTree.Select(Term.Select(Term.Ident("java"), "lang"), "String"), Some(Term.Match(Term.Ident("x$1"), List(CaseDef(Pattern.Value(Term.Ident("_")), None, Term.Apply(Term.Ident("throw"), List(Term.Apply(Term.Select(Term.New(TypeTree.Select(Term.Select(Term.Ident("java"), "lang"), "IndexOutOfBoundsException")), ""), List(Term.Apply(Term.Select(Term.Select(Term.Select(Term.Ident("java"), "lang"), "String"), "valueOf"), List(Term.Ident("x$1")))))))))))), DefDef("copy", Nil, List(Nil), TypeTree.Inferred(), Some(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil))))), ValDef("Foo", TypeTree.Ident("Foo$"), Some(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo$")), ""), Nil))), ClassDef("Foo$", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Applied(TypeTree.Inferred(), List(TypeTree.Inferred())), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Serializable")), Nil, Some(ValDef("_", TypeTree.Singleton(Term.Ident("Foo")), None)), List(DefDef("apply", Nil, List(Nil), TypeTree.Inferred(), Some(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil))), DefDef("unapply", Nil, List(List(ValDef("x$1", TypeTree.Inferred(), None))), TypeTree.Inferred(), Some(Term.Literal(Constant.Boolean(true))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo1", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None)))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo2", DefDef("", Nil, List(List(ValDef("b", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("b", TypeTree.Inferred(), None)))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo3", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None))), ValDef("Foo3", TypeTree.Ident("Foo3$"), Some(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo3$")), ""), Nil))), ClassDef("Foo3$", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Serializable")), Nil, Some(ValDef("_", TypeTree.Singleton(Term.Ident("Foo3")), None)), List(DefDef("$lessinit$greater$default$1", Nil, Nil, TypeTree.Inferred(), Some(Term.Literal(Constant.Int(5))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo4", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None)), List(ValDef("b", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None), ValDef("b", TypeTree.Inferred(), None)))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo5", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None)), List(ValDef("b", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None), ValDef("b", TypeTree.Inferred(), None))), ValDef("Foo5", TypeTree.Ident("Foo5$"), Some(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo5$")), ""), Nil))), ClassDef("Foo5$", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Select(Term.Select(Term.Ident("_root_"), "scala"), "Serializable")), Nil, Some(ValDef("_", TypeTree.Singleton(Term.Ident("Foo5")), None)), List(DefDef("$lessinit$greater$default$2", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), Some(Term.Ident("a")))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo6", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None)), List(ValDef("b", TypeTree.Singleton(Term.Ident("a")), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None), ValDef("b", TypeTree.Inferred(), None)))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo7", DefDef("", Nil, List(List(ValDef("a", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), None), DefDef("", Nil, List(Nil), TypeTree.Inferred(), Some(Term.Block(List(Term.Apply(Term.Select(Term.This(Some(Id("Foo7"))), ""), List(Term.Literal(Constant.Int(6))))), Term.Literal(Constant.Unit()))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo8", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(Term.Apply(Term.Ident("println"), List(Term.Literal(Constant.Int(0))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo10", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(9))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo11", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(10)))), DefDef("a_=", Nil, List(List(ValDef("x$1", TypeTree.Inferred(), None))), TypeTree.Inferred(), Some(Term.Literal(Constant.Unit())))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo12", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("a", TypeTree.Inferred(), Some(Term.Literal(Constant.Int(11))))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo")), ""), Nil)), Nil, None, Nil)), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo2", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(TypeTree.Inferred()), Nil, None, Nil), ClassDef("Bar", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil), TypeTree.Ident("Foo2")), Nil, None, Nil)), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(List(ValDef("i", TypeTree.Ident("Int"), None))), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(ValDef("i", TypeTree.Inferred(), None))), ClassDef("Bar", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Ident("Foo")), ""), List(Term.Literal(Constant.Int(1))))), Nil, None, Nil)), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeTree.Ident("Int")))), DefDef("f", Nil, List(List(ValDef("a", TypeTree.Ident("Foo"), None))), TypeTree.Select(Term.Ident("a"), "X"), Some(Term.Ident("???")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ClassDef("Foo", DefDef("", Nil, List(Nil), TypeTree.Inferred(), None), List(Term.Apply(Term.Select(Term.New(TypeTree.Inferred()), ""), Nil)), Nil, None, List(TypeDef("X", TypeBoundsTree(TypeTree.Inferred(), TypeTree.Inferred())))), DefDef("f", Nil, List(List(ValDef("a", TypeTree.Refined(TypeTree.Ident("Foo"), List(TypeDef("X", TypeTree.Ident("Int")))), None))), TypeTree.Select(Term.Ident("a"), "X"), Some(Term.Ident("???")))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) Term.Inlined(None, Nil, Term.Block(List(ValDef("lambda", TypeTree.Applied(TypeTree.Inferred(), List(TypeTree.Ident("Int"), TypeTree.Ident("Int"))), Some(Term.Block(List(DefDef("$anonfun", Nil, List(List(ValDef("x", TypeTree.Inferred(), None))), TypeTree.Inferred(), Some(Term.Ident("x")))), Term.Lambda(Term.Ident("$anonfun"), None))))), Term.Literal(Constant.Unit()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) diff --git a/tests/run/tasty-extractors-3.check b/tests/run/tasty-extractors-3.check index c543ea5cf05e..2e3b9f23e983 100644 --- a/tests/run/tasty-extractors-3.check +++ b/tests/run/tasty-extractors-3.check @@ -1,42 +1,42 @@ -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsValSymbol(), NoPrefix()) +Type.SymRef(IsValDefSymbol(), NoPrefix()) -TypeBounds(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +TypeBounds(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsTypeSymbol(), NoPrefix()) +Type.SymRef(IsTypeDefSymbol(), NoPrefix()) -TypeBounds(Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))), Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix()))))) +TypeBounds(Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))), Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix()))))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) -Type.SymRef(IsTypeSymbol(), NoPrefix()) +Type.SymRef(IsTypeDefSymbol(), NoPrefix()) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -TypeBounds(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +TypeBounds(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.Refinement(Type.SymRef(IsClassSymbol(), NoPrefix()), X, TypeBounds(Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))), Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))))) +Type.Refinement(Type.SymRef(IsClassDefSymbol(), NoPrefix()), X, TypeBounds(Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))), Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))))) -Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))) +Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))) -Type.SymRef(IsClassSymbol(), NoPrefix()) +Type.SymRef(IsClassDefSymbol(), NoPrefix()) -Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))) +Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))) -Type.SymRef(IsClassSymbol(), NoPrefix()) +Type.SymRef(IsClassDefSymbol(), NoPrefix()) -Type.Refinement(Type.SymRef(IsClassSymbol(), NoPrefix()), X, TypeBounds(Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))), Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))))) +Type.Refinement(Type.SymRef(IsClassDefSymbol(), NoPrefix()), X, TypeBounds(Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))), Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))))) diff --git a/tests/run/tasty-extractors-types.check b/tests/run/tasty-extractors-types.check index d0f0bc486a20..b198d9dae9c6 100644 --- a/tests/run/tasty-extractors-types.check +++ b/tests/run/tasty-extractors-types.check @@ -1,12 +1,12 @@ TypeTree.Inferred() -Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))) +Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))) TypeTree.Inferred() -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))))) TypeTree.Inferred() -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))), Type.SymRef(IsClassSymbol(), Type.SymRef(IsPackageSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(<>), NoPrefix())))))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))), Type.SymRef(IsClassDefSymbol(), Type.SymRef(IsPackageDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(<>), NoPrefix())))))) TypeTree.Inferred() -Type.AppliedType(Type.SymRef(IsClassSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeSymbol(), Type.SymRef(IsValSymbol(), Type.ThisType(Type.SymRef(IsPackageSymbol(), NoPrefix())))), Type.SymRef(IsTypeSymbol(), NoPrefix()))) +Type.AppliedType(Type.SymRef(IsClassDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix()))), List(Type.SymRef(IsTypeDefSymbol(), Type.SymRef(IsValDefSymbol(), Type.ThisType(Type.SymRef(IsPackageDefSymbol(), NoPrefix())))), Type.SymRef(IsTypeDefSymbol(), NoPrefix()))) diff --git a/tests/run/tasty-macro-assert/quoted_1.scala b/tests/run/tasty-macro-assert/quoted_1.scala index feac01ef6173..0e97464c5d12 100644 --- a/tests/run/tasty-macro-assert/quoted_1.scala +++ b/tests/run/tasty-macro-assert/quoted_1.scala @@ -20,7 +20,7 @@ object Asserts { val tree = cond.unseal def isOps(tpe: TypeOrBounds): Boolean = tpe match { - case Type.SymRef(IsDefSymbol(sym), _) => sym.name == "Ops"// TODO check that the parent is Asserts + case Type.SymRef(IsDefDefSymbol(sym), _) => sym.name == "Ops"// TODO check that the parent is Asserts case _ => false }