summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-08-06 10:45:31 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-08-06 10:45:31 -0700
commit4389ce5e10a425dd215d3cd474e681b205770bb0 (patch)
tree452e0c51cc69e58b4658f501fe5cd80975dfaf69
parentba402c457aecf7d94038534775b7b063d7d5bd9e (diff)
parentf6f15279aabe71348f78deb78cdd6f802852a446 (diff)
downloadscala-4389ce5e10a425dd215d3cd474e681b205770bb0.tar.gz
scala-4389ce5e10a425dd215d3cd474e681b205770bb0.tar.bz2
scala-4389ce5e10a425dd215d3cd474e681b205770bb0.zip
Merge pull request #1047 from scalamacros/topic/moar-symbol-tests
adds more tests for api.Symbols
-rw-r--r--src/reflect/scala/reflect/api/Symbols.scala42
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala4
2 files changed, 46 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index 13f5f743f1..2fa8ccc044 100644
--- a/src/reflect/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -158,10 +158,22 @@ trait Symbols extends base.Symbols { self: Universe =>
*/
def isOverride: Boolean
+ /** Is this symbol labelled as "abstract override"?
+ */
+ def isAbstractOverride: Boolean
+
/** Is this symbol a macro?
*/
def isMacro: Boolean
+ /** Is this symbol a parameter (either a method parameter or a type parameter)?
+ */
+ def isParameter: Boolean
+
+ /** Is this symbol a specialized type parameter or a generated specialized member?
+ */
+ def isSpecialized: Boolean
+
/******************* helpers *******************/
/** ...
@@ -240,6 +252,25 @@ trait Symbols extends base.Symbols { self: Universe =>
/** Setter method for a backing field of a val or a val, NoSymbol for all other term symbols.
*/
def setter: Symbol
+
+ /** Does this symbol represent a field of a class
+ * that was generated from a parameter of that class?
+ */
+ def isParamAccessor: Boolean
+
+ /** Does this symbol represent a field of a case class
+ * that corresponds to a parameter in the first parameter list of the
+ * primary constructor of that class?
+ */
+ def isCaseAccessor: Boolean
+
+ /** Does this symbol represent a parameter with a default value?
+ */
+ def isParamWithDefault: Boolean
+
+ /** Does this symbol represent a by-name parameter?
+ */
+ def isByNameParam: Boolean
}
/** The API of type symbols */
@@ -275,6 +306,13 @@ trait Symbols extends base.Symbols { self: Universe =>
/** The API of method symbols */
trait MethodSymbolApi extends TermSymbolApi with MethodSymbolBase { this: MethodSymbol =>
+ /** 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.
+ */
+ def isConstructor: Boolean
+
/** For a polymorphic method, its type parameters, the empty list for all other methods */
def typeParams: List[Symbol]
@@ -286,6 +324,10 @@ trait Symbols extends base.Symbols { self: Universe =>
*/
def params: List[List[Symbol]]
+ /** Does this method support variable length argument lists?
+ */
+ def isVarargs: Boolean
+
/** The return type of the method */
def returnType: Type
}
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index c356416112..9ae4302734 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -64,6 +64,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def kind: String = kindString
def isExistential: Boolean = this.isExistentiallyBound
+ def isParamWithDefault: Boolean = this.hasDefault
+ def isByNameParam: Boolean = this.isValueParameter && (this hasFlag BYNAMEPARAM)
def newNestedSymbol(name: Name, pos: Position, newFlags: Long, isClass: Boolean): Symbol = name match {
case n: TermName => newTermSymbol(n, pos, newFlags)
@@ -2496,6 +2498,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def params: List[List[Symbol]] = paramss
+ override def isVarargs: Boolean = definitions.isVarArgsList(paramss.flatten)
+
override def returnType: Type = {
def loop(tpe: Type): Type =
tpe match {