summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Names.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-07-13 12:09:16 -0700
committerPaul Phillips <paulp@improving.org>2012-07-13 12:25:08 -0700
commitb355fb2c7f622c2d263c43864469b862ef0bc768 (patch)
tree2f47f42921a20c8e4e7b85229e793caa2c236001 /src/reflect/scala/reflect/internal/Names.scala
parent453b7068ed4294eef18bf10a321a5b63497c7466 (diff)
downloadscala-b355fb2c7f622c2d263c43864469b862ef0bc768.tar.gz
scala-b355fb2c7f622c2d263c43864469b862ef0bc768.tar.bz2
scala-b355fb2c7f622c2d263c43864469b862ef0bc768.zip
Avoid conflict with String's apply.
This brought to light that Name extends (Int => Char), and that small convenience was not paying for itself. I updated the places taking advantage of it to use Name#charAt.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Names.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Names.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala
index 3c0848f77f..20da38fd63 100644
--- a/src/reflect/scala/reflect/internal/Names.scala
+++ b/src/reflect/scala/reflect/internal/Names.scala
@@ -145,7 +145,7 @@ trait Names extends api.Names with LowPriorityNames {
* or Strings as Names. Give names the key functions the absence of which
* make people want Strings all the time.
*/
- sealed abstract class Name(protected val index: Int, protected val len: Int) extends NameApi with Function1[Int, Char] {
+ sealed abstract class Name(protected val index: Int, protected val len: Int) extends NameApi {
type ThisNameType >: Null <: Name
protected[this] def thisName: ThisNameType
@@ -226,7 +226,7 @@ trait Names extends api.Names with LowPriorityNames {
}
/** @return the i'th Char of this name */
- final def apply(i: Int): Char = chrs(index + i)
+ final def charAt(i: Int): Char = chrs(index + i)
/** @return the index of first occurrence of char c in this name, length if not found */
final def pos(c: Char): Int = pos(c, 0)
@@ -355,8 +355,8 @@ trait Names extends api.Names with LowPriorityNames {
/** Some thoroughly self-explanatory convenience functions. They
* assume that what they're being asked to do is known to be valid.
*/
- final def startChar: Char = apply(0)
- final def endChar: Char = apply(len - 1)
+ final def startChar: Char = this charAt 0
+ final def endChar: Char = this charAt len - 1
final def startsWith(char: Char): Boolean = len > 0 && startChar == char
final def startsWith(name: String): Boolean = startsWith(newTermName(name))
final def endsWith(char: Char): Boolean = len > 0 && endChar == char
@@ -380,7 +380,7 @@ trait Names extends api.Names with LowPriorityNames {
val cs = new Array[Char](len)
var i = 0
while (i < len) {
- val ch = this(i)
+ val ch = charAt(i)
cs(i) = if (ch == from) to else ch
i += 1
}