From 9ea3a4ac2cb36ee8519deab04fd1bd6be81a89cb Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 27 Sep 2013 09:20:48 -0700 Subject: SI-6762 rename emptyValDef to noSelfType. Looks like emptyValDef.isEmpty was already changed to return false, so now all that's left is a name which means something. --- src/reflect/scala/reflect/api/Printers.scala | 4 ++-- src/reflect/scala/reflect/api/Trees.scala | 20 ++++++++------------ src/reflect/scala/reflect/internal/BuildUtils.scala | 4 ++-- src/reflect/scala/reflect/internal/Importers.scala | 6 +++--- src/reflect/scala/reflect/internal/Printers.scala | 4 ++-- src/reflect/scala/reflect/internal/StdNames.scala | 2 +- src/reflect/scala/reflect/internal/Trees.scala | 6 ++++-- 7 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src/reflect') diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 81d30dec1e..6e2e2c3781 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -48,7 +48,7 @@ import java.io.{ PrintWriter, StringWriter } * res1: String = Block(List( * ClassDef(Modifiers(FINAL), newTypeName("C"), List(), Template( * List(Ident(newTypeName("AnyRef"))), - * emptyValDef, + * noSelfType, * List( * DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), * Block(List( @@ -72,7 +72,7 @@ import java.io.{ PrintWriter, StringWriter } * res2: String = Block[1](List( * ClassDef[2](Modifiers(FINAL), newTypeName("C"), List(), Template[3]( * List(Ident[4](newTypeName("AnyRef"))), - * emptyValDef, + * noSelfType, * List( * DefDef[2](Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree[3](), * Block[1](List( diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index 7a627bc875..fa7d41f0fc 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -71,20 +71,13 @@ trait Trees { self: Universe => /** Is this tree one of the empty trees? * - * Empty trees are: the `EmptyTree` null object, `TypeTree` instances that don't carry a type - * and the special `emptyValDef` singleton. - * - * In the compiler the `isEmpty` check and the derived `orElse` method are mostly used - * as a check for a tree being a null object (`EmptyTree` for term trees and empty TypeTree for type trees). - * - * Unfortunately `emptyValDef` is also considered to be `isEmpty`, but this is deemed to be - * a conceptual mistake pending a fix in https://issues.scala-lang.org/browse/SI-6762. + * Empty trees are: the `EmptyTree` null object and `TypeTree` instances that don't carry a type. * * @see `canHaveAttrs` */ def isEmpty: Boolean - /** Is this tree one of the empty trees? + /** Is this tree not an empty tree? * * @see `isEmpty` */ @@ -92,7 +85,7 @@ trait Trees { self: Universe => /** Can this tree carry attributes (i.e. symbols, types or positions)? * Typically the answer is yes, except for the `EmptyTree` null object and - * two special singletons: `emptyValDef` and `pendingSuperCall`. + * two special singletons: `noSelfType` and `pendingSuperCall`. */ def canHaveAttrs: Boolean @@ -856,7 +849,7 @@ trait Trees { self: Universe => def parents: List[Tree] /** Self type of the template. - * Is equal to `emptyValDef` if the self type is not specified. + * Is equal to `noSelfType` if the self type is not specified. */ def self: ValDef @@ -2121,6 +2114,9 @@ trait Trees { self: Universe => * no definition of a self value of self type. * @group Trees */ + val noSelfType: ValDef + + @deprecated("Use `noSelfType` instead", "2.11.0") val emptyValDef: ValDef /** An empty superclass constructor call corresponding to: @@ -2635,7 +2631,7 @@ trait Trees { self: Universe => trees mapConserve (tree => transform(tree).asInstanceOf[TypeDef]) /** Transforms a `ValDef`. */ def transformValDef(tree: ValDef): ValDef = - if (tree eq emptyValDef) tree + if (tree eq noSelfType) tree else transform(tree).asInstanceOf[ValDef] /** Transforms a list of `ValDef` nodes. */ def transformValDefs(trees: List[ValDef]): List[ValDef] = diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index e5c7dc44af..25186ae95b 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -63,7 +63,7 @@ trait BuildUtils { self: SymbolTable => def setSymbol[T <: Tree](tree: T, sym: Symbol): T = { tree.setSymbol(sym); tree } def mkAnnotation(tree: Tree): Tree = tree match { - case SyntacticNew(Nil, SyntacticApplied(SyntacticTypeApplied(_, _), _) :: Nil, emptyValDef, Nil) => + case SyntacticNew(Nil, SyntacticApplied(SyntacticTypeApplied(_, _), _) :: Nil, noSelfType, Nil) => tree case _ => throw new IllegalArgumentException(s"Tree ${showRaw(tree)} isn't a correct representation of annotation." + @@ -364,7 +364,7 @@ trait BuildUtils { self: SymbolTable => def unapply(tree: Tree): Option[(List[Tree], List[Tree], ValDef, List[Tree])] = tree match { case SyntacticApplied(Select(New(SyntacticTypeApplied(ident, targs)), nme.CONSTRUCTOR), argss) => - Some((Nil, SyntacticApplied(SyntacticTypeApplied(ident, targs), argss) :: Nil, emptyValDef, Nil)) + Some((Nil, SyntacticApplied(SyntacticTypeApplied(ident, targs), argss) :: Nil, noSelfType, Nil)) case SyntacticBlock(SyntacticClassDef(_, tpnme.ANON_CLASS_NAME, Nil, _, ListOfNil, earlyDefs, parents, selfdef, body) :: Apply(Select(New(Ident(tpnme.ANON_CLASS_NAME)), nme.CONSTRUCTOR), Nil) :: Nil) => Some((earlyDefs, parents, selfdef, body)) diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index 9ddf156128..72c8ccfa62 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -308,8 +308,8 @@ trait Importers extends api.Importers { to: SymbolTable => new PackageDef(importRefTree(pid), stats map importTree) case from.ModuleDef(mods, name, impl) => new ModuleDef(importModifiers(mods), importName(name).toTermName, importTemplate(impl)) - case from.emptyValDef => - emptyValDef + case from.noSelfType => + noSelfType case from.pendingSuperCall => pendingSuperCall case from.ValDef(mods, name, tpt, rhs) => @@ -412,7 +412,7 @@ trait Importers extends api.Importers { to: SymbolTable => addFixup(recreatedTreeCompleter(their, my)) tryFixup() // we have to be careful with position import as some shared trees - // like EmptyTree, emptyValDef don't support position assignment + // like EmptyTree, noSelfType don't support position assignment if (their.pos != NoPosition) { my.setPos(importPosition(their.pos)) } diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 206dff44e2..424e73dce8 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -549,8 +549,8 @@ trait Printers extends api.Printers { self: SymbolTable => print(")") case EmptyTree => print("EmptyTree") - case self.emptyValDef => - print("emptyValDef") + case self.noSelfType => + print("noSelfType") case self.pendingSuperCall => print("pendingSuperCall") case tree: Tree => diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index f4eae5590a..dc5c6704bc 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -661,7 +661,7 @@ trait StdNames { val dollarScope: NameType = "$scope" val drop: NameType = "drop" val elem: NameType = "elem" - val emptyValDef: NameType = "emptyValDef" + val noSelfType: NameType = "noSelfType" val ensureAccessible : NameType = "ensureAccessible" val eq: NameType = "eq" val equalsNumChar : NameType = "equalsNumChar" diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 2163a26b84..b1fc27f832 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1037,9 +1037,11 @@ trait Trees extends api.Trees { self: SymbolTable => } case object EmptyTree extends TermTree with CannotHaveAttrs { override def isEmpty = true; val asList = List(this) } - object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) with CannotHaveAttrs + object noSelfType extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) with CannotHaveAttrs object pendingSuperCall extends Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List()) with CannotHaveAttrs + @deprecated("Use `noSelfType` instead", "2.11.0") lazy val emptyValDef = noSelfType + def newValDef(sym: Symbol, rhs: Tree)( mods: Modifiers = Modifiers(sym.flags), name: TermName = sym.name.toTermName, @@ -1196,7 +1198,7 @@ trait Trees extends api.Trees { self: SymbolTable => traverse(annot); traverse(arg) case Template(parents, self, body) => traverseTrees(parents) - if (self ne emptyValDef) traverse(self) + if (self ne noSelfType) traverse(self) traverseStats(body, tree.symbol) case Block(stats, expr) => traverseTrees(stats); traverse(expr) -- cgit v1.2.3