diff options
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Chars.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala index 74413fdaba..0f532a4e57 100644 --- a/src/reflect/scala/reflect/internal/Chars.scala +++ b/src/reflect/scala/reflect/internal/Chars.scala @@ -66,7 +66,7 @@ trait Chars { '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' /** Can character start an alphanumeric Scala identifier? */ - def isIdentifierStart(c: Char): Boolean = + def isIdentifierStart(c: Char): Boolean = (c == '_') || (c == '$') || Character.isUnicodeIdentifierStart(c) /** Can character form part of an alphanumeric Scala identifier? */ diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 05fdfb51ed..c3b2a8da08 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -503,6 +503,19 @@ trait Symbols extends api.Symbols { self: SymbolTable => case _ => new StubTermSymbol(this, name.toTermName, missingMessage) } + /** Given a field, construct a term symbol that represents the source construct that gave rise the the field */ + def sugaredSymbolOrSelf = { + val getter = getterIn(owner) + if (getter == NoSymbol) { + this + } else { + val result = owner.newValue(getter.name.toTermName, newFlags = getter.flags & ~Flags.METHOD).setPrivateWithin(getter.privateWithin).setInfo(getter.info.resultType) + val setter = setterIn(owner) + if (setter != NoSymbol) result.setFlag(Flags.MUTABLE) + result + } + } + // ----- locking and unlocking ------------------------------------------------------ // True if the symbol is unlocked. |