diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-01 00:46:07 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-15 09:23:51 +0100 |
commit | fa8f4022754356859f3af1c4ffbac02ab3dc3e7c (patch) | |
tree | 967f7ba7625c63c7d87b0ef659afb8516c589def /src | |
parent | 462d0b8b1c9de95baad773856a7e1f658ebd0956 (diff) | |
download | scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.tar.gz scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.tar.bz2 scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.zip |
some renamings
It’s almost 1am, so I’m only scratching the surface, mechanistically
applying the renames that I’ve written down in my notebook:
* typeSignature => info
* declarations => decls
* nme/tpnme => termNames/typeNames
* paramss => paramLists
* allOverriddenSymbols => overrides
Some explanation is in order so that I don’t get crucified :)
1) No information loss happens when abbreviating `typeSignature` and `declarations`.
We already have contractions in a number of our public APIs (e.g. `typeParams`),
and I think it’s fine to shorten words as long as people can understand
the shortened versions without a background in scalac.
2) I agree with Simon that `nme` and `tpnme` are cryptic. I think it would
be thoughtful of us to provide newcomers with better names. To offset
the increase in mouthfulness, I’ve moved `MethodSymbol.isConstructor`
to `Symbol.isConstructor`, which covers the most popular use case for nme’s.
3) I also agree that putting `paramss` is a lot to ask of our users.
The double-“s” convention is very neat, but let’s admit that it’s just
weird for the newcomers. I think `paramLists` is a good compromise here.
4) `allOverriddenSymbols` is my personal complaint. I think it’s a mouthful
and a shorter name would be a much better fit for the public API.
Diffstat (limited to 'src')
22 files changed, 135 insertions, 84 deletions
diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index 5f8de9894f..b6ae3b8952 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -162,7 +162,7 @@ trait SymbolTables { else if (isFreeTerm) sym.tpe else sym.info } else NoType - val rset = reifier.mirrorBuildCall(nme.setTypeSignature, currtab.symRef(sym), reifier.reify(signature)) + val rset = reifier.mirrorBuildCall(nme.setInfo, currtab.symRef(sym), reifier.reify(signature)) // `Symbol.annotations` doesn't initialize the symbol, so we don't need to do anything special here // also since we call `sym.info` a few lines above, by now the symbol will be initialized (if possible) // so the annotations will be filled in and will be waiting to be reified (unless symbol initialization is prohibited as described above) diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index ce6382bec8..3cae6fa8a8 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -137,7 +137,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => // it inaccessible then please put it somewhere designed for that // rather than polluting the empty package with synthetics. val ownerClass = rootMirror.EmptyPackageClass.newClassSymbol(newTypeName("<expression-owner>")) - build.setTypeSignature(ownerClass, ClassInfoType(List(ObjectTpe), newScope, ownerClass)) + build.setInfo(ownerClass, ClassInfoType(List(ObjectTpe), newScope, ownerClass)) val owner = ownerClass.newLocalDummy(expr.pos) val currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _) diff --git a/src/reflect/scala/reflect/api/Constants.scala b/src/reflect/scala/reflect/api/Constants.scala index c654961f4a..e73c5ffa91 100644 --- a/src/reflect/scala/reflect/api/Constants.scala +++ b/src/reflect/scala/reflect/api/Constants.scala @@ -69,7 +69,7 @@ package api * val enumRef = jarg("enumRef").symbolValue * println(enumRef) // value BAR * - * val siblings = enumRef.owner.typeSignature.declarations + * val siblings = enumRef.owner.info.decls * val enumValues = siblings.filter(sym => sym.isVal && sym.isPublic) * println(enumValues) // Scope{ * // final val FOO: JavaSimpleEnumeration; @@ -165,7 +165,7 @@ trait Constants { * // ideally one should match instead of casting * println(enumRef) // value BAR * - * val siblings = enumRef.owner.typeSignature.declarations + * val siblings = enumRef.owner.info.decls * val enumValues = siblings.filter(sym => sym.isVal && sym.isPublic) * println(enumValues) // Scope{ * // final val FOO: JavaSimpleEnumeration; diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala index 2957113ba5..7d9fec3be0 100644 --- a/src/reflect/scala/reflect/api/Internals.scala +++ b/src/reflect/scala/reflect/api/Internals.scala @@ -399,7 +399,7 @@ trait Internals { self: Universe => /** Set symbol's type signature to given type. * @return the symbol itself */ - def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S + def setInfo[S <: Symbol](sym: S, tpe: Type): S /** Set symbol's annotations to given annotations `annots`. */ @@ -1005,7 +1005,7 @@ trait Internals { self: Universe => @deprecated("This API is unreliable. Use `isPrivateThis` or `isProtectedThis` instead", "2.11.0") def isLocal: Boolean = symbol.asInstanceOf[scala.reflect.internal.Symbols#Symbol].isLocal - @deprecated("This API is unreliable. Use `allOverriddenSymbols.nonEmpty` instead", "2.11.0") + @deprecated("This API is unreliable. Use `overrides.nonEmpty` instead", "2.11.0") def isOverride: Boolean = symbol.asInstanceOf[scala.reflect.internal.Symbols#Symbol].isOverride /** @see [[InternalApi.isFreeTerm]] */ diff --git a/src/reflect/scala/reflect/api/Mirror.scala b/src/reflect/scala/reflect/api/Mirror.scala index e0219c9074..48fc8dede4 100644 --- a/src/reflect/scala/reflect/api/Mirror.scala +++ b/src/reflect/scala/reflect/api/Mirror.scala @@ -58,7 +58,7 @@ abstract class Mirror[U <: Universe with Singleton] { * scala> cm.staticPackage("scala") * res2: scala.reflect.runtime.universe.ModuleSymbol = package scala * - * scala> res2.moduleClass.typeSignature member newTypeName("List") + * scala> res2.moduleClass.info member newTypeName("List") * res3: scala.reflect.runtime.universe.Symbol = type List * * scala> res3.fullName @@ -83,7 +83,7 @@ abstract class Mirror[U <: Universe with Singleton] { * fully qualified class name is written inside any package in a Scala program). * * In the example above, to load a symbol that corresponds to the class B declared in the object foo, - * use staticModule("foo") to load the module symbol and then navigate typeSignature.members of its moduleClass. + * use staticModule("foo") to load the module symbol and then navigate info.members of its moduleClass. * @group Mirror */ def staticClass(fullName: String): U#ClassSymbol @@ -110,7 +110,7 @@ abstract class Mirror[U <: Universe with Singleton] { * fully qualified class name is written inside any package in a Scala program). * * In the example above, to load a symbol that corresponds to the object B declared in the object foo, - * use staticModule("foo") to load the module symbol and then navigate typeSignature.members of its moduleClass. + * use staticModule("foo") to load the module symbol and then navigate info.members of its moduleClass. * @group Mirror */ def staticModule(fullName: String): U#ModuleSymbol diff --git a/src/reflect/scala/reflect/api/Mirrors.scala b/src/reflect/scala/reflect/api/Mirrors.scala index f688001f95..03a3c8c0fb 100644 --- a/src/reflect/scala/reflect/api/Mirrors.scala +++ b/src/reflect/scala/reflect/api/Mirrors.scala @@ -260,8 +260,8 @@ trait Mirrors { self: Universe => * Note also that only accessor MethodMirrors, but not FieldMirrors will accurately reflect overriding behavior. * * To get a field symbol by the name of the field you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the field>)).asTerm.accessed`. - * For further information about member lookup refer to `Symbol.typeSignature`. + * use `<this mirror>.symbol.info.member(TermName(<name of the field>)).asTerm.accessed`. + * For further information about member lookup refer to `Symbol.info`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). * It must be a member (declared or inherited) of the class of the instance underlying this mirror. @@ -280,8 +280,8 @@ trait Mirrors { self: Universe => * that can be used to invoke the method provided. * * To get a method symbol by the name of the method you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the method>)).asMethod`. - * For further information about member lookup refer to `Symbol.typeSignature`. + * use `<this mirror>.symbol.info.member(TermName(<name of the method>)).asMethod`. + * For further information about member lookup refer to `Symbol.info`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). * It must be a member (declared or inherited) of the instance underlying this mirror. @@ -292,8 +292,8 @@ trait Mirrors { self: Universe => * that can be used to create instances of the class, inspect its companion object or perform further reflections. * * To get a class symbol by the name of the class you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(newTypeName(<name of the class>)).asClass`. - * For further information about member lookup refer to `Symbol.typeSignature`. + * use `<this mirror>.symbol.info.member(newTypeName(<name of the class>)).asClass`. + * For further information about member lookup refer to `Symbol.info`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). * It must be a member (declared or inherited) of the instance underlying this mirror. @@ -304,8 +304,8 @@ trait Mirrors { self: Universe => * that can be used to get the instance of the object or inspect its companion class. * * To get a module symbol by the name of the object you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(TermName(<name of the object>)).asModule`. - * For further information about member lookup refer to `Symbol.typeSignature`. + * use `<this mirror>.symbol.info.member(TermName(<name of the object>)).asModule`. + * For further information about member lookup refer to `Symbol.info`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). * It must be a member (declared or inherited) of the instance underlying this mirror. @@ -437,8 +437,8 @@ trait Mirrors { self: Universe => * that can be used to invoke it and construct instances of this mirror's symbols. * * To get a constructor symbol you would like to reflect, - * use `<this mirror>.symbol.typeSignature.member(nme.CONSTRUCTOR).asMethod`. - * For further information about member lookup refer to `Symbol.typeSignature`. + * use `<this mirror>.symbol.info.member(termNames.CONSTRUCTOR).asMethod`. + * For further information about member lookup refer to `Symbol.info`. * * The input symbol can be either private or non-private (Scala reflection transparently deals with visibility). * It must be a member (declared or inherited) of the class underlying this mirror. diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 96e111f759..6f634c55fe 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -266,5 +266,5 @@ trait Printers { self: Universe => /** Renders a string that represents a declaration of this symbol written in Scala. * @group Printers */ - def showDeclaration(sym: Symbol): String + def showDecl(sym: Symbol): String } diff --git a/src/reflect/scala/reflect/api/Scopes.scala b/src/reflect/scala/reflect/api/Scopes.scala index 3f926d68f2..c9142fba47 100644 --- a/src/reflect/scala/reflect/api/Scopes.scala +++ b/src/reflect/scala/reflect/api/Scopes.scala @@ -16,7 +16,7 @@ package api * there is the `newScopeWith` function. * * Additional functionality is exposed in member scopes that are returned by - * `members` and `declarations` defined in [[scala.reflect.api.Types#TypeApi]]. + * `members` and `decls` defined in [[scala.reflect.api.Types#TypeApi]]. * Such scopes support the `sorted` method, which sorts members in declaration order. * * @group ReflectionAPI diff --git a/src/reflect/scala/reflect/api/StandardDefinitions.scala b/src/reflect/scala/reflect/api/StandardDefinitions.scala index 1a8885e6b5..524b7ea14b 100644 --- a/src/reflect/scala/reflect/api/StandardDefinitions.scala +++ b/src/reflect/scala/reflect/api/StandardDefinitions.scala @@ -131,10 +131,10 @@ trait StandardDefinitions { * scala> val m = typeOf[C].member(newTermName("m")).asMethod * m: reflect.runtime.universe.MethodSymbol = method m * - * scala> m.params(0)(0).typeSignature + * scala> m.params(0)(0).info * res1: reflect.runtime.universe.Type = => scala.Int * - * scala> showRaw(m.params(0)(0).typeSignature) + * scala> showRaw(m.params(0)(0).info) * res2: String = TypeRef( * ThisType(scala), * scala.<byname>, // <-- ByNameParamClass @@ -159,10 +159,10 @@ trait StandardDefinitions { * scala> val m = typeOf[C].member(newTermName("m")).asMethod * m: reflect.runtime.universe.MethodSymbol = method m * - * scala> m.params(0)(0).typeSignature + * scala> m.params(0)(0).info * res1: reflect.runtime.universe.Type = <repeated...>[Object] * - * scala> showRaw(m.params(0)(0).typeSignature) + * scala> showRaw(m.params(0)(0).info) * res2: String = TypeRef( * ThisType(scala), * scala.<repeated...>, // <-- JavaRepeatedParamClass @@ -184,10 +184,10 @@ trait StandardDefinitions { * scala> val m = typeOf[C].member(newTermName("m")).asMethod * m: reflect.runtime.universe.MethodSymbol = method m * - * scala> m.params(0)(0).typeSignature + * scala> m.params(0)(0).info * res1: reflect.runtime.universe.Type = scala.Int* * - * scala> showRaw(m.params(0)(0).typeSignature) + * scala> showRaw(m.params(0)(0).info) * res2: String = TypeRef( * ThisType(scala), * scala.<repeated>, // <-- RepeatedParamClass diff --git a/src/reflect/scala/reflect/api/StandardNames.scala b/src/reflect/scala/reflect/api/StandardNames.scala index aec5f19fa0..19bdfcae59 100644 --- a/src/reflect/scala/reflect/api/StandardNames.scala +++ b/src/reflect/scala/reflect/api/StandardNames.scala @@ -28,15 +28,23 @@ package api trait StandardNames { self: Universe => + /** @see [[termNames]] */ + @deprecated("Use `termNames` instead", "2.11.0") + val nme: TermNamesApi + /** A value containing all [[TermNamesApi standard term names]]. * @group StandardNames */ - val nme: TermNamesApi + val termNames: TermNamesApi + + /** @see [[typeNames]] */ + @deprecated("Use `typeNames` instead", "2.11.0") + val tpnme: TypeNamesApi /** A value containing all [[TypeNamesApi standard type names]]. * @group StandardNames */ - val tpnme: TypeNamesApi + val typeNames: TypeNamesApi /** Defines standard names, common for term and type names: These can be accessed via the [[nme]] and [[tpnme]] members. * @group API diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index 5f9334e358..c7c23ea9f2 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -30,7 +30,7 @@ package api * scala> val test = typeOf[C[Int]].member(newTermName("test")).asMethod * test: reflect.runtime.universe.MethodSymbol = method test * - * scala> test.typeSignature + * scala> test.info * res0: reflect.runtime.universe.Type = [U](x: T)(y: U)scala.Int * }}} * @@ -202,6 +202,15 @@ trait Symbols { self: Universe => */ def isMethod: Boolean = false + /** Does this method represent a constructor? + * + * If `owner` is a class, then this is a vanilla JVM constructor. + * If `owner` is a trait, then this is a mixin constructor. + * + * @group Method + */ + def isConstructor: Boolean + /** This symbol cast to a MethodSymbol. * @throws ScalaReflectionException if `isMethod` is false. * @@ -295,11 +304,19 @@ trait Symbols { self: Universe => */ def companion: Symbol + /** @see [[infoIn]] */ + @deprecated("Use `infoIn` instead", "2.11.0") + def typeSignatureIn(site: Type): Type + /** The type signature of this symbol seen as a member of given type `site`. * * @group Basics */ - def typeSignatureIn(site: Type): Type + def infoIn(site: Type): Type + + /** @see [[info]] */ + @deprecated("Use `info` instead", "2.11.0") + def typeSignature: Type /** The type signature of this symbol. * @@ -307,17 +324,21 @@ trait Symbols { self: Universe => * instantiation of a generic type. For example, signature * of the method `def map[B](f: (A) ⇒ B): List[B]`, which refers to the type parameter `A` of the declaring class `List[A]`, * will always feature `A`, regardless of whether `map` is loaded from the `List[_]` or from `List[Int]`. To get a signature - * with type parameters appropriately instantiated, one should use `typeSignatureIn`. + * with type parameters appropriately instantiated, one should use `infoIn`. * * @group Basics */ - def typeSignature: Type + def info: Type + + /** @see [[overrides]] */ + @deprecated("Use `overrides` instead", "2.11.0") + def allOverriddenSymbols: List[Symbol] /** Returns all symbols overriden by this symbol. * * @group Basics */ - def allOverriddenSymbols: List[Symbol] + def overrides: List[Symbol] /** The overloaded alternatives of this symbol * @@ -659,7 +680,7 @@ trait Symbols { self: Universe => * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol * `C`. Then `C.toType` is the type `C[T]`. * - * By contrast, `C.typeSignature` would be a type signature of form + * By contrast, `C.info` would be a type signature of form * `PolyType(ClassInfoType(...))` that describes type parameters, value * parameters, parent types, and members of `C`. * @@ -718,15 +739,6 @@ trait Symbols { self: Universe => final override def isMethod = true final override def asMethod = this - /** Does this method represent a constructor? - * - * If `owner` is a class, then this is a vanilla JVM constructor. - * If `owner` is a trait, then this is a mixin constructor. - * - * @group Method - */ - def isConstructor: Boolean - /** Does this symbol denote the primary constructor of its enclosing class? * * @group Method @@ -739,6 +751,10 @@ trait Symbols { self: Universe => */ def typeParams: List[Symbol] + /** @see [[paramLists]] */ + @deprecated("Use `paramLists` instead", "2.11.0") + def paramss: List[List[Symbol]] + /** All parameter lists of the method. * The name ending with "ss" indicates that the result type is a list of lists. * @@ -748,7 +764,7 @@ trait Symbols { self: Universe => * * @group Method */ - def paramss: List[List[Symbol]] + def paramLists: List[List[Symbol]] /** Does this method support variable length argument lists? * diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala index dd63211c32..a0b3e672c5 100644 --- a/src/reflect/scala/reflect/api/Types.scala +++ b/src/reflect/scala/reflect/api/Types.scala @@ -94,11 +94,19 @@ trait Types { */ def typeSymbol: Symbol + /** @see [[decl]] */ + @deprecated("Use `decl` instead", "2.11.0") + def declaration(name: Name): Symbol + /** The defined or declared members with name `name` in this type; * an OverloadedSymbol if several exist, NoSymbol if none exist. * Alternatives of overloaded symbol appear in the order they are declared. */ - def declaration(name: Name): Symbol + def decl(name: Name): Symbol + + /** @see [[decls]] */ + @deprecated("Use `decls` instead", "2.11.0") + def declarations: MemberScope /** A `Scope` containing directly declared members of this type. * Unlike `members` this method doesn't returns inherited members. @@ -106,7 +114,7 @@ trait Types { * Members in the returned scope might appear in arbitrary order. * Use `declarations.sorted` to get an ordered list of members. */ - def declarations: MemberScope + def decls: MemberScope /** The member with given name, either directly declared or inherited, * an OverloadedSymbol if several exist, NoSymbol if none exist. @@ -251,10 +259,14 @@ trait Types { */ def typeArgs: List[Type] + /** @see [[paramLists]] */ + @deprecated("Use `paramLists` instead", "2.11.0") + def paramss: List[List[Symbol]] + /** For a method or poly type, a list of its value parameter sections, * the empty list of lists for all other types. */ - def paramss: List[List[Symbol]] + def paramLists: List[List[Symbol]] /** For a poly type, its type parameters, * the empty list for all other types. @@ -271,7 +283,7 @@ trait Types { * scala> typeOf[C].member(TermName("foo")).asMethod * res0: reflect.runtime.universe.MethodSymbol = method foo * - * scala> res0.typeSignature // PolyType wrapping a MethodType + * scala> res0.info // PolyType wrapping a MethodType * res1: reflect.runtime.universe.Type = [T](x: T)(y: T)scala.Nothing * * scala> res1.resultType // MethodType wrapping a MethodType @@ -299,7 +311,7 @@ trait Types { * scala> typeOf[C].member(TermName("foo")).asMethod * res0: reflect.runtime.universe.MethodSymbol = method foo * - * scala> res0.typeSignature // PolyType wrapping a MethodType + * scala> res0.info // PolyType wrapping a MethodType * res1: reflect.runtime.universe.Type = [T](x: T)(y: T)scala.Nothing * * scala> res1.resultType // MethodType wrapping a MethodType @@ -610,7 +622,7 @@ trait Types { def parents: List[Type] /** The scope that holds the definitions comprising the type. */ - def decls: Scope + def decls: MemberScope } /** The `ClassInfo` type signature is used to define parents and declarations @@ -651,7 +663,7 @@ trait Types { def parents: List[Type] /** The scope that holds the definitions comprising the class type. */ - def decls: Scope + def decls: MemberScope /** The symbol underlying the class type. */ def typeSymbol: Symbol diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala index 43a118217d..a152787ae1 100644 --- a/src/reflect/scala/reflect/internal/Internals.scala +++ b/src/reflect/scala/reflect/internal/Internals.scala @@ -96,7 +96,7 @@ trait Internals extends api.Internals { def updateAttachment[T: ClassTag](symbol: Symbol, attachment: T): symbol.type = symbol.updateAttachment(attachment) def removeAttachment[T: ClassTag](symbol: Symbol): symbol.type = symbol.removeAttachment[T] def pos(symbol: Symbol): Position = symbol.pos - def setTypeSignature(symbol: Symbol, tpe: Type): symbol.type = symbol.setTypeSignature(tpe) + def setInfo(symbol: Symbol, tpe: Type): symbol.type = symbol.setInfo(tpe) def setAnnotations(symbol: Symbol, annots: Annotation*): symbol.type = symbol.setAnnotations(annots: _*) def setName(symbol: Symbol, name: Name): symbol.type = symbol.setName(name) def setPrivateWithin(symbol: Symbol, sym: Symbol): symbol.type = symbol.setPrivateWithin(sym) diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 0a9e291abe..8ec4c98cd9 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -1211,17 +1211,17 @@ trait Printers extends api.Printers { self: SymbolTable => } def show(name: Name): String = name match { - case tpnme.WILDCARD => "tpnme.WILDCARD" - case tpnme.EMPTY => "tpnme.EMPTY" - case tpnme.ERROR => "tpnme.ERROR" - case tpnme.PACKAGE => "tpnme.PACKAGE" - case tpnme.WILDCARD_STAR => "tpnme.WILDCARD_STAR" - case nme.WILDCARD => "nme.WILDCARD" - case nme.EMPTY => "nme.EMPTY" - case nme.ERROR => "tpnme.ERROR" - case nme.PACKAGE => "nme.PACKAGE" - case nme.CONSTRUCTOR => "nme.CONSTRUCTOR" - case nme.ROOTPKG => "nme.ROOTPKG" + case tpnme.WILDCARD => "typeNames.WILDCARD" + case tpnme.EMPTY => "typeNames.EMPTY" + case tpnme.ERROR => "typeNames.ERROR" + case tpnme.PACKAGE => "typeNames.PACKAGE" + case tpnme.WILDCARD_STAR => "typeNames.WILDCARD_STAR" + case nme.WILDCARD => "termNames.WILDCARD" + case nme.EMPTY => "termNames.EMPTY" + case nme.ERROR => "termNames.ERROR" + case nme.PACKAGE => "termNames.PACKAGE" + case nme.CONSTRUCTOR => "termNames.CONSTRUCTOR" + case nme.ROOTPKG => "termNames.ROOTPKG" case _ => val prefix = if (name.isTermName) "TermName(\"" else "TypeName(\"" prefix + name.toString + "\")" @@ -1242,7 +1242,7 @@ trait Printers extends api.Printers { self: SymbolTable => position.show } - def showDeclaration(sym: Symbol): String = { + def showDecl(sym: Symbol): String = { if (!isCompilerUniverse) definitions.fullyInitializeSymbol(sym) sym.defString } diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala index 00ed9fb963..d4be708181 100644 --- a/src/reflect/scala/reflect/internal/ReificationSupport.scala +++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala @@ -48,8 +48,8 @@ trait ReificationSupport { self: SymbolTable => def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S = sym.setAnnotations(annots) - def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S = - sym.setTypeSignature(tpe).markAllCompleted() + def setInfo[S <: Symbol](sym: S, tpe: Type): S = + sym.setInfo(tpe).markAllCompleted() def This(sym: Symbol): Tree = self.This(sym) diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 192735805d..afb003b450 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -757,9 +757,9 @@ trait StdNames { val selectType: NameType = "selectType" val self: NameType = "self" val setAnnotations: NameType = "setAnnotations" + val setInfo: NameType = "setInfo" val setSymbol: NameType = "setSymbol" val setType: NameType = "setType" - val setTypeSignature: NameType = "setTypeSignature" val splice: NameType = "splice" val staticClass : NameType = "staticClass" val staticModule : NameType = "staticModule" @@ -1000,6 +1000,8 @@ trait StdNames { val BITMAP_CHECKINIT_TRANSIENT: NameType = BITMAP_PREFIX + "inittrans$" // initialization bitmap for transient checkinit values } + lazy val typeNames: tpnme.type = tpnme + object tpnme extends TypeNames { } /** For fully qualified type names. @@ -1020,6 +1022,8 @@ trait StdNames { val javanme = nme.javaKeywords + lazy val termNames: nme.type = nme + object nme extends TermNames { def moduleVarName(name: TermName): TermName = newTermNameCached("" + name + MODULE_VAR_SUFFIX) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index c4fc450a78..35c7a59683 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -134,7 +134,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => def toType: Type = tpe def toTypeIn(site: Type): Type = site.memberType(this) def toTypeConstructor: Type = typeConstructor - def setTypeSignature(tpe: Type): this.type = { setInfo(tpe); this } def setAnnotations(annots: AnnotationInfo*): this.type = { setAnnotations(annots.toList); this } def getter: Symbol = getter(owner) @@ -146,6 +145,10 @@ trait Symbols extends api.Symbols { self: SymbolTable => else if (isClass && !isModuleClass && !isPackageClass) companionSymbol else NoSymbol } + + def infoIn(site: Type): Type = typeSignatureIn(site) + def overrides: List[Symbol] = allOverriddenSymbols + def paramLists: List[List[Symbol]] = paramss } private[reflect] case class SymbolKind(accurate: String, sanitized: String, abbreviation: String) @@ -645,7 +648,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => * (i.e. the pickle not only contains info about directly nested classes/modules, but also about * classes/modules nested into those and so on). * - * Unpickling is triggered automatically whenever typeSignature (info in compiler parlance) is called. + * Unpickling is triggered automatically whenever info (info in compiler parlance) is called. * This happens because package symbols assign completer thunks to the dummies they create. * Therefore metadata loading happens lazily and transparently. * @@ -655,7 +658,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => * produces incorrect results. * * One might think that the solution is simple: automatically call the completer - * whenever one needs flags, annotations and privateWithin - just like it's done for typeSignature. + * whenever one needs flags, annotations and privateWithin - just like it's done for info. * Unfortunately, this leads to weird crashes in scalac, and currently we can't attempt * to fix the core of the compiler risk stability a few weeks before the final release. * upd. Haha, "a few weeks before the final release". This surely sounds familiar :) @@ -2526,6 +2529,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => * If hasMeaninglessName is true, uses the owner's name to disambiguate identity. */ override def toString: String = { + if (!isCompilerUniverse) fullyInitializeSymbol(this) if (isPackageObjectOrClass && !settings.debug) s"package object ${owner.decodedName}" else compose( diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 5bcfde7256..3bcc07caca 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -251,6 +251,8 @@ trait Types else if (sym.isClass && !sym.isModuleClass && !sym.isPackageClass) sym.companionSymbol.info else NoType } + + def paramLists: List[List[Symbol]] = paramss } /** The base class for all types */ @@ -918,7 +920,10 @@ trait Types * after `maxTostringRecursions` recursion levels. Uses `safeToString` * to produce a string on each level. */ - override final def toString: String = typeToString(this) + override final def toString: String = { + if (!isCompilerUniverse) fullyInitializeType(this) + typeToString(this) + } /** Method to be implemented in subclasses. * Converts this type to a string in calling toString for its parts. diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index e69805cfc1..23cd23cdb0 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -61,8 +61,8 @@ abstract class Universe extends scala.reflect.api.Universe { /** The position of this symbol. */ def pos(symbol: Symbol): Position - /** Sets the `typeSignature` of the symbol. */ - def setTypeSignature(symbol: Symbol, tpe: Type): symbol.type + /** Sets the `info` of the symbol. */ + def setInfo(symbol: Symbol, tpe: Type): symbol.type /** Sets the `annotations` of the symbol. */ def setAnnotations(symbol: Symbol, annots: Annotation*): symbol.type @@ -236,9 +236,9 @@ abstract class Universe extends scala.reflect.api.Universe { @deprecated("Use `internal.pos` instead", "2.11.0") def pos: Position = internal.pos(symbol) - /** @see [[InternalMacroApi.setTypeSignature]] */ - @deprecated("Use `internal.setTypeSignature` instead", "2.11.0") - def setTypeSignature(tpe: Type): Symbol = internal.setTypeSignature(symbol, tpe) + /** @see [[InternalMacroApi.setInfo]] */ + @deprecated("Use `internal.setInfo` instead", "2.11.0") + def setTypeSignature(tpe: Type): Symbol = internal.setInfo(symbol, tpe) /** @see [[InternalMacroApi.setAnnotations]] */ @deprecated("Use `internal.setAnnotations` instead", "2.11.0") diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 963e4dd3be..1c942e8858 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -145,7 +145,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive object ConstantArg { def enumToSymbol(enum: Enum[_]): Symbol = { val staticPartOfEnum = classToScala(enum.getClass).companionSymbol - staticPartOfEnum.typeSignature.declaration(enum.name: TermName) + staticPartOfEnum.info.declaration(enum.name: TermName) } def unapply(schemaAndValue: (jClass[_], Any)): Option[Any] = schemaAndValue match { @@ -269,7 +269,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive val isDerivedValueClass = symbol.isDerivedValueClass lazy val boxer = runtimeClass(symbol.toType).getDeclaredConstructors().head lazy val unboxer = { - val fields @ (field :: _) = symbol.toType.declarations.collect{ case ts: TermSymbol if ts.isParamAccessor && ts.isMethod => ts }.toList + val fields @ (field :: _) = symbol.toType.decls.collect{ case ts: TermSymbol if ts.isParamAccessor && ts.isMethod => ts }.toList assert(fields.length == 1, s"$symbol: $fields") runtimeClass(symbol.asClass).getDeclaredMethod(field.name.toString) } @@ -292,7 +292,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive jfield.set(receiver, if (isDerivedValueClass) unboxer.invoke(value) else value) } - override def toString = s"field mirror for ${showDeclaration(symbol)} (bound to $receiver)" + override def toString = s"field mirror for ${showDecl(symbol)} (bound to $receiver)" } // the "symbol == Any_getClass || symbol == Object_getClass" test doesn't cut it @@ -347,7 +347,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive override def toString = { val what = if (symbol.isConstructor) "constructor mirror" else "method mirror" - s"$what for ${showDeclaration(symbol)} (bound to $receiver)" + s"$what for ${showDecl(symbol)} (bound to $receiver)" } } @@ -443,7 +443,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive private class BytecodelessMethodMirror[T: ClassTag](val receiver: T, val symbol: MethodSymbol) extends MethodMirror { def bind(newReceiver: Any) = new BytecodelessMethodMirror(newReceiver.asInstanceOf[T], symbol) - override def toString = s"bytecodeless method mirror for ${showDeclaration(symbol)} (bound to $receiver)" + override def toString = s"bytecodeless method mirror for ${showDecl(symbol)} (bound to $receiver)" def apply(args: Any*): Any = { // checking type conformance is too much of a hassle, so we don't do it here @@ -457,7 +457,7 @@ private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUnive if (!perfectMatch && !varargMatch) { val n_arguments = if (isVarArgsList(params)) s"${params.length - 1} or more" else s"${params.length}" val s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" - abort(s"${showDeclaration(symbol)} takes $n_arguments $s_arguments") + abort(s"${showDecl(symbol)} takes $n_arguments $s_arguments") } def objReceiver = receiver.asInstanceOf[AnyRef] diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index 01655bdb54..dcd262c288 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -108,9 +108,11 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => this.UnmappableAnnotation this.ErroneousAnnotation this.ThrownException + this.typeNames this.tpnme this.fulltpnme this.binarynme + this.termNames this.nme this.sn this.Constant diff --git a/src/repl/scala/tools/nsc/interpreter/package.scala b/src/repl/scala/tools/nsc/interpreter/package.scala index 5dc9b65436..079097d7a2 100644 --- a/src/repl/scala/tools/nsc/interpreter/package.scala +++ b/src/repl/scala/tools/nsc/interpreter/package.scala @@ -157,7 +157,7 @@ package object interpreter extends ReplConfig with ReplStrings { def echoKind(tpe: Type, kind: Kind, verbose: Boolean) { def typeString(tpe: Type): String = { tpe match { - case TypeRef(_, sym, _) => typeString(sym.typeSignature) + case TypeRef(_, sym, _) => typeString(sym.info) case RefinedType(_, _) => tpe.toString case _ => tpe.typeSymbol.fullName } |