summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/api/Symbols.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/reflect/api/Symbols.scala')
-rwxr-xr-xsrc/library/scala/reflect/api/Symbols.scala149
1 files changed, 94 insertions, 55 deletions
diff --git a/src/library/scala/reflect/api/Symbols.scala b/src/library/scala/reflect/api/Symbols.scala
index d9293888d9..767246a294 100755
--- a/src/library/scala/reflect/api/Symbols.scala
+++ b/src/library/scala/reflect/api/Symbols.scala
@@ -4,8 +4,101 @@ package api
trait Symbols { self: Universe =>
type Symbol >: Null <: AbsSymbol
+ type TypeSymbol <: Symbol with TypeSymbolApi
+ type TermSymbol <: Symbol with TermSymbolApi
+ type MethodSymbol <: TermSymbol with MethodSymbolApi
+ type ModuleSymbol <: TermSymbol with ModuleSymbolApi
+ type PackageSymbol <: ModuleSymbol with PackageSymbolApi
+ type ClassSymbol <: TypeSymbol with ClassSymbolApi
- abstract class AbsSymbol { this: Symbol =>
+ val NoSymbol: Symbol
+
+ trait TypeSymbolApi {
+ self: TypeSymbol =>
+
+ def name: TypeName
+ }
+ trait TermSymbolApi {
+ self: TermSymbol =>
+
+ def name: TermName
+ }
+ trait MethodSymbolApi extends TermSymbolApi {
+ self: MethodSymbol =>
+ }
+ trait ClassSymbolApi extends TypeSymbolApi {
+ self: ClassSymbol =>
+ }
+ trait ModuleSymbolApi extends TermSymbolApi {
+ self: ModuleSymbol =>
+ }
+ trait PackageSymbolApi extends ModuleSymbolApi {
+ self: PackageSymbol =>
+ }
+
+ // I intend to pull everything in here out of the public API.
+ trait AbsSymbolInternal {
+ this: Symbol =>
+
+ /** A fresh symbol with given name `name`, position `pos` and flags `flags` that has
+ * the current symbol as its owner.
+ */
+ def newNestedSymbol(name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol
+ // needed by LiftCode !!! not enough reason to have in the api
+
+ /** Low-level operation to set the symbol's flags
+ * @return the symbol itself
+ */
+ def setInternalFlags(flags: Long): this.type
+ // needed by LiftCode !!! not enough reason to have in the api
+
+ /** Set symbol's type signature to given type
+ * @return the symbol itself
+ */
+ def setTypeSignature(tpe: Type): this.type
+ // needed by LiftCode !!! not enough reason to have in the api
+
+ /** Set symbol's annotations to given annotations `annots`.
+ */
+ def setAnnotations(annots: AnnotationInfo*): this.type
+ // needed by LiftCode !!! not enough reason to have in the api
+
+ /** Does this symbol represent the definition of a skolem?
+ * Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
+ * If yes, `isType` is also guaranteed to be true.
+ */
+ def isSkolem : Boolean
+
+ /** Does this symbol represent a free type captured by reification?
+ */
+ // needed for ones who wish to inspect reified trees
+ def isFreeType : Boolean
+
+ /** The type signature of this symbol.
+ * Note if the symbol is a member of a class, one almost always is interested
+ * in `typeSignatureIn` with a site type instead.
+ */
+ def typeSignature: Type // !!! Since one should almost never use this, let's give it a different name.
+
+ /** A type reference that refers to this type symbol
+ * Note if symbol is a member of a class, one almost always is interested
+ * in `asTypeIn` with a site type instead.
+ *
+ * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
+ * `C`. Then `C.asType` is the type `C[T]`.
+ *
+ * By contrast, `C.typeSignature` would be a type signature of form
+ * `PolyType(ClassInfoType(...))` that describes type parameters, value
+ * parameters, parent types, and members of `C`.
+ */
+ def asType: Type // !!! Same as typeSignature.
+
+ /** The kind of this symbol; used for debugging */
+ def kind: String
+ }
+
+ trait AbsSymbol extends AbsSymbolInternal {
+ this: Symbol =>
/** The position of this symbol
*/
@@ -177,22 +270,11 @@ trait Symbols { self: Universe =>
*/
def isAbstractType : Boolean
- /** Does this symbol represent the definition of a skolem?
- * Skolems are used during typechecking to represent type parameters viewed from inside their scopes.
- * If yes, `isType` is also guaranteed to be true.
- */
- def isSkolem : Boolean
-
/** Does this symbol represent an existentially bound type?
* If yes, `isType` is also guaranteed to be true.
*/
def isExistential : Boolean
- /** Does this symbol represent a free type captured by reification?
- */
- // needed for ones who wish to inspect reified trees
- def isFreeType : Boolean
-
/** Is the type parameter represented by this symbol contravariant?
*/
def isContravariant : Boolean
@@ -205,29 +287,10 @@ trait Symbols { self: Universe =>
*/
def isErroneous : Boolean
- /** The type signature of this symbol.
- * Note if the symbol is a member of a class, one almost always is interested
- * in `typeSignatureIn` with a site type instead.
- */
- def typeSignature: Type // !!! Since one should almost never use this, let's give it a different name.
-
/** The type signature of this symbol seen as a member of given type `site`.
*/
def typeSignatureIn(site: Type): Type
- /** A type reference that refers to this type symbol
- * Note if symbol is a member of a class, one almost always is interested
- * in `asTypeIn` with a site type instead.
- *
- * Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
- * `C`. Then `C.asType` is the type `C[T]`.
- *
- * By contrast, `C.typeSignature` would be a type signature of form
- * `PolyType(ClassInfoType(...))` that describes type parameters, value
- * parameters, parent types, and members of `C`.
- */
- def asType: Type // !!! Same as typeSignature.
-
/** A type reference that refers to this type symbol seen
* as a member of given type `site`.
*/
@@ -255,29 +318,5 @@ trait Symbols { self: Universe =>
def alternatives: List[Symbol]
def resolveOverloaded(pre: Type = NoPrefix, targs: Seq[Type] = List(), actuals: Seq[Type]): Symbol
-
- /** A fresh symbol with given name `name`, position `pos` and flags `flags` that has
- * the current symbol as its owner.
- */
- def newNestedSymbol(name: Name, pos: Position, flags: Long, isClass: Boolean): Symbol // needed by LiftCode !!! not enough reason to have in the api
-
- /** Low-level operation to set the symbol's flags
- * @return the symbol itself
- */
- def setInternalFlags(flags: Long): this.type // needed by LiftCode !!! not enough reason to have in the api
-
- /** Set symbol's type signature to given type
- * @return the symbol itself
- */
- def setTypeSignature(tpe: Type): this.type // needed by LiftCode !!! not enough reason to have in the api
-
- /** Set symbol's annotations to given annotations `annots`.
- */
- def setAnnotations(annots: AnnotationInfo*): this.type // needed by LiftCode !!! not enough reason to have in the api
-
- /** The kind of this symbol; used for debugging */
- def kind: String
}
-
- val NoSymbol: Symbol
}