summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/base/Symbols.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/reflect/base/Symbols.scala')
-rw-r--r--src/library/scala/reflect/base/Symbols.scala54
1 files changed, 36 insertions, 18 deletions
diff --git a/src/library/scala/reflect/base/Symbols.scala b/src/library/scala/reflect/base/Symbols.scala
index ced1f33395..052571dbcb 100644
--- a/src/library/scala/reflect/base/Symbols.scala
+++ b/src/library/scala/reflect/base/Symbols.scala
@@ -134,7 +134,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a TypeSymbol.
* Returns ClassCastException if `isType` is false.
*/
- def asTypeSymbol: TypeSymbol = throw new ClassCastException(toString)
+ def asType: TypeSymbol = throw new ClassCastException(toString)
/** Does this symbol represent the definition of a term?
* Note that every symbol is either a term or a term.
@@ -146,7 +146,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a TermSymbol.
* Returns ClassCastException if `isTerm` is false.
*/
- def asTermSymbol: TermSymbol = throw new ClassCastException(toString)
+ def asTerm: TermSymbol = throw new ClassCastException(toString)
/** Does this symbol represent the definition of a method?
* If yes, `isTerm` is also guaranteed to be true.
@@ -156,7 +156,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a MethodSymbol.
* Returns ClassCastException if `isMethod` is false.
*/
- def asMethodSymbol: MethodSymbol = throw new ClassCastException(toString)
+ def asMethod: MethodSymbol = throw new ClassCastException(toString)
/** Does this symbol represent the definition of a module (i.e. it
* results from an object definition?).
@@ -167,7 +167,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a ModuleSymbol defined by an object definition.
* Returns ClassCastException if `isModule` is false.
*/
- def asModuleSymbol: ModuleSymbol = throw new ClassCastException(toString)
+ def asModule: ModuleSymbol = throw new ClassCastException(toString)
/** Does this symbol represent the definition of a class or trait?
* If yes, `isType` is also guaranteed to be true.
@@ -183,7 +183,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a ClassSymbol representing a class or trait.
* Returns ClassCastException if `isClass` is false.
*/
- def asClassSymbol: ClassSymbol = throw new ClassCastException(toString)
+ def asClass: ClassSymbol = throw new ClassCastException(toString)
/** Does this symbol represent a free term captured by reification?
* If yes, `isTerm` is also guaranteed to be true.
@@ -193,7 +193,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a free term symbol.
* Returns ClassCastException if `isFreeTerm` is false.
*/
- def asFreeTermSymbol: FreeTermSymbol = throw new ClassCastException(toString)
+ def asFreeTerm: FreeTermSymbol = throw new ClassCastException(toString)
/** Does this symbol represent a free type captured by reification?
* If yes, `isType` is also guaranteed to be true.
@@ -203,7 +203,7 @@ trait Symbols { self: Universe =>
/** This symbol cast to a free type symbol.
* Returns ClassCastException if `isFreeType` is false.
*/
- def asFreeTypeSymbol: FreeTypeSymbol = throw new ClassCastException(toString)
+ def asFreeType: FreeTypeSymbol = throw new ClassCastException(toString)
def newTermSymbol(name: TermName, pos: Position = NoPosition, flags: FlagSet = NoFlags): TermSymbol
def newModuleAndClassSymbol(name: Name, pos: Position = NoPosition, flags: FlagSet = NoFlags): (ModuleSymbol, ClassSymbol)
@@ -219,16 +219,34 @@ trait Symbols { self: Universe =>
final type NameType = TypeName
/** The type constructor corresponding to this type symbol.
- * This is different from `asType` in that type parameters
- * are part of results of `asType`, but not of `asTypeConstructor`.
+ * This is different from `toType` in that type parameters
+ * are part of results of `toType`, but not of `toTypeConstructor`.
*
* Example: Given a class declaration `class C[T] { ... } `, that generates a symbol
- * `C`. Then `C.asType` is the type `C[T]`, but `C.asTypeConstructor` is `C`.
+ * `C`. Then `C.toType` is the type `C[T]`, but `C.toTypeConstructor` is `C`.
*/
- def asTypeConstructor: Type
+ def toTypeConstructor: Type
+
+ /** A type reference that refers to this type symbol seen
+ * as a member of given type `site`.
+ */
+ def toTypeIn(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.toType` 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 toType: Type
override def isType = true
- override def asTypeSymbol = this
+ override def asType = this
}
/** The base API that all term symbols support */
@@ -238,13 +256,13 @@ trait Symbols { self: Universe =>
final type NameType = TermName
final override def isTerm = true
- final override def asTermSymbol = this
+ final override def asTerm = this
}
/** The base API that all method symbols support */
trait MethodSymbolBase extends TermSymbolBase { this: MethodSymbol =>
final override def isMethod = true
- final override def asMethodSymbol = this
+ final override def asMethod = this
}
/** The base API that all module symbols support */
@@ -257,24 +275,24 @@ trait Symbols { self: Universe =>
// [Eugene++] when this becomes `moduleClass: ClassSymbol`, it will be the happiest day in my life
final override def isModule = true
- final override def asModuleSymbol = this
+ final override def asModule = this
}
/** The base API that all class symbols support */
trait ClassSymbolBase extends TypeSymbolBase { this: ClassSymbol =>
final override def isClass = true
- final override def asClassSymbol = this
+ final override def asClass = this
}
/** The base API that all free type symbols support */
trait FreeTypeSymbolBase extends TypeSymbolBase { this: FreeTypeSymbol =>
final override def isFreeType = true
- final override def asFreeTypeSymbol = this
+ final override def asFreeType = this
}
/** The base API that all free term symbols support */
trait FreeTermSymbolBase extends TermSymbolBase { this: FreeTermSymbol =>
final override def isFreeTerm = true
- final override def asFreeTermSymbol = this
+ final override def asFreeTerm = this
}
}