diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-08-06 16:31:18 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-06 16:31:18 +0200 |
commit | f6f15279aabe71348f78deb78cdd6f802852a446 (patch) | |
tree | 4aa95940e3f26d3c5383f594320db4213b938fe2 | |
parent | ec4a9fb5251bed30f4d99091d66190c1bd9daa03 (diff) | |
download | scala-f6f15279aabe71348f78deb78cdd6f802852a446.tar.gz scala-f6f15279aabe71348f78deb78cdd6f802852a446.tar.bz2 scala-f6f15279aabe71348f78deb78cdd6f802852a446.zip |
adds more tests for api.Symbols
I overlooked some of the tests that should be added to the public API.
This commit fixes my mistake. Also see 027b00171c.
To reiterate the reasoning behind introduction of test methods into the API.
I'd argue that the API duplication w.r.t flags is trumped by unified interface
to tests and better encapsulation (especially since some of the flags have
different meaning depending on whether the flaggee is a term or a type).
-rw-r--r-- | src/reflect/scala/reflect/api/Symbols.scala | 42 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 4 |
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 { |