diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-09-02 13:13:06 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-09-02 13:43:17 +1000 |
commit | 9a3089bd4ac68db798ac006731ebd1b99e9aaaff (patch) | |
tree | 0ecb18e1b3e6945df81f02412af63868979be6c0 /test/junit | |
parent | f9b52c7086ad1541cb949dd4ff2412990bde792e (diff) | |
download | scala-9a3089bd4ac68db798ac006731ebd1b99e9aaaff.tar.gz scala-9a3089bd4ac68db798ac006731ebd1b99e9aaaff.tar.bz2 scala-9a3089bd4ac68db798ac006731ebd1b99e9aaaff.zip |
Add a convenience method to Symbol to "resugar" fields
val and var members of classes are split into getter/setter and field
symbols. However, we can't call `defString` on any of these and see
what existed in source code.
Example:
```
scala> class X { protected var x: Int = 0 }
defined class X
scala> val xField = typeOf[X].member(TermName("x "))
xField: $r.intp.global.Symbol = variable x
scala> xField.defString
res10: String = private[this] var x: Int
scala> xField.getterIn(xField.owner).defString
res11: String = protected def x: Int
scala> xField.setterIn(xField.owner).defString
res12: String = protected def x_=(x$1: Int): Unit
```
This commit introduces a new method on `Symbol` that pieces together
the information from these symbols to create an artificial symbol
that has the `defString` we're after:
```
scala> xField.sugaredSymbolOrSelf.defString
res14: String = protected var x: Int
```
Diffstat (limited to 'test/junit')
0 files changed, 0 insertions, 0 deletions