summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-08-27 18:08:19 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-08-27 20:21:46 +0200
commit23cf705ba64641a3ba45e84984702cf97cdd0ccf (patch)
tree1d8238b702ff0fca3d8377c8a9e00805e95d6525 /src
parente81cafe1d444e2e2c7422c93f85f1e8382816a6a (diff)
downloadscala-23cf705ba64641a3ba45e84984702cf97cdd0ccf.tar.gz
scala-23cf705ba64641a3ba45e84984702cf97cdd0ccf.tar.bz2
scala-23cf705ba64641a3ba45e84984702cf97cdd0ccf.zip
definitive way to learn if a symbol is a val/var
I think `isVal` and `isVar` are the right names, because they exactly map on Scala syntax.
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/api/Symbols.scala8
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index 2673069eef..8617ae975d 100644
--- a/src/reflect/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -212,16 +212,16 @@ trait Symbols extends base.Symbols { self: Universe =>
/** The API of term symbols */
trait TermSymbolApi extends SymbolApi with TermSymbolBase { this: TermSymbol =>
- /** Does this symbol represent a value, i.e. not a module and not a method?
+ /** Is this symbol introduced as `val`?
*/
- def isValue: Boolean
+ def isVal: Boolean
/** Does this symbol denote a stable value? */
def isStable: Boolean
- /** Does this symbol represent a mutable value?
+ /** Is this symbol introduced as `var`?
*/
- def isVariable: Boolean
+ def isVar: Boolean
/** Does this symbol represent a getter or a setter?
*/
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 07614361c5..4d60566474 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -70,6 +70,8 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def isByNameParam: Boolean = this.isValueParameter && (this hasFlag BYNAMEPARAM)
def isImplementationArtifact: Boolean = (this hasFlag BRIDGE) || (this hasFlag VBRIDGE) || (this hasFlag ARTIFACT)
def isJava: Boolean = this hasFlag JAVA
+ def isVal: Boolean = isTerm && !isModule && !isMethod && !isMutable
+ def isVar: Boolean = isTerm && !isModule && !isMethod && isMutable
def newNestedSymbol(name: Name, pos: Position, newFlags: Long, isClass: Boolean): Symbol = name match {
case n: TermName => newTermSymbol(n, pos, newFlags)