summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
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/compiler/scala/tools
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/compiler/scala/tools')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaScanners.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala32
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala2
5 files changed, 21 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index 316faba6e2..b545140c4a 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -522,7 +522,7 @@ trait DocComments { self: Global =>
val substAliases = new TypeMap {
def apply(tp: Type) = mapOver(tp) match {
- case tp1 @ TypeRef(pre, sym, args) if (sym.name.length > 1 && sym.name(0) == '$') =>
+ case tp1 @ TypeRef(pre, sym, args) if (sym.name.length > 1 && sym.name.startChar == '$') =>
subst(sym, aliases, aliasExpansions) match {
case TypeRef(pre1, sym1, _) =>
typeRef(pre1, sym1, args)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 3232bde3b4..e0c9631246 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -763,7 +763,7 @@ self =>
def precedence(operator: Name): Int =
if (operator eq nme.ERROR) -1
else {
- val firstCh = operator(0)
+ val firstCh = operator.startChar
if (isScalaLetter(firstCh)) 1
else if (nme.isOpAssignmentName(operator)) 0
else firstCh match {
diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
index 73b5a752b4..a37fdc3ed1 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
@@ -778,7 +778,7 @@ trait JavaScanners extends ast.parser.ScannersCommon {
*/
def intVal(negated: Boolean): Long = {
if (token == CHARLIT && !negated) {
- if (name.length > 0) name(0) else 0
+ if (name.length > 0) name.charAt(0) else 0
} else {
var value: Long = 0
val divider = if (base == 10) 1 else 2
@@ -787,7 +787,7 @@ trait JavaScanners extends ast.parser.ScannersCommon {
var i = 0
val len = name.length
while (i < len) {
- val d = digit2int(name(i), base)
+ val d = digit2int(name.charAt(i), base)
if (d < 0) {
syntaxError("malformed integer number")
return 0
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index e6499c05a6..86f9d38203 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -307,7 +307,7 @@ abstract class ClassfileParser {
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
- if (name(0) == ARRAY_TAG) {
+ if (name.charAt(0) == ARRAY_TAG) {
c = sigToType(null, name)
values(index) = c
} else {
@@ -667,16 +667,16 @@ abstract class ClassfileParser {
var index = 0
val end = sig.length
def accept(ch: Char) {
- assert(sig(index) == ch, (sig(index), ch))
+ assert(sig.charAt(index) == ch, (sig.charAt(index), ch))
index += 1
}
def subName(isDelimiter: Char => Boolean): Name = {
val start = index
- while (!isDelimiter(sig(index))) { index += 1 }
+ while (!isDelimiter(sig.charAt(index))) { index += 1 }
sig.subName(start, index)
}
def sig2type(tparams: immutable.Map[Name,Symbol], skiptvs: Boolean): Type = {
- val tag = sig(index); index += 1
+ val tag = sig.charAt(index); index += 1
tag match {
case BYTE_TAG => definitions.ByteClass.tpe
case CHAR_TAG => definitions.CharClass.tpe
@@ -697,12 +697,12 @@ abstract class ClassfileParser {
def processClassType(tp: Type): Type = tp match {
case TypeRef(pre, classSym, args) =>
val existentials = new ListBuffer[Symbol]()
- if (sig(index) == '<') {
+ if (sig.charAt(index) == '<') {
accept('<')
val xs = new ListBuffer[Type]()
var i = 0
- while (sig(index) != '>') {
- sig(index) match {
+ while (sig.charAt(index) != '>') {
+ sig.charAt(index) match {
case variance @ ('+' | '-' | '*') =>
index += 1
val bounds = variance match {
@@ -738,14 +738,14 @@ abstract class ClassfileParser {
res
}
case tp =>
- assert(sig(index) != '<', tp)
+ assert(sig.charAt(index) != '<', tp)
tp
}
val classSym = classNameToSymbol(subName(c => c == ';' || c == '<'))
assert(!classSym.isOverloaded, classSym.alternatives)
var tpe = processClassType(processInner(classSym.tpe))
- while (sig(index) == '.') {
+ while (sig.charAt(index) == '.') {
accept('.')
val name = subName(c => c == ';' || c == '<' || c == '.').toTypeName
val clazz = tpe.member(name)
@@ -754,7 +754,7 @@ abstract class ClassfileParser {
accept(';')
tpe
case ARRAY_TAG =>
- while ('0' <= sig(index) && sig(index) <= '9') index += 1
+ while ('0' <= sig.charAt(index) && sig.charAt(index) <= '9') index += 1
var elemtp = sig2type(tparams, skiptvs)
// make unbounded Array[T] where T is a type variable into Array[T with Object]
// (this is necessary because such arrays have a representation which is incompatible
@@ -771,7 +771,7 @@ abstract class ClassfileParser {
// we need a method symbol. given in line 486 by calling getType(methodSym, ..)
assert(sym ne null, sig)
val paramtypes = new ListBuffer[Type]()
- while (sig(index) != ')') {
+ while (sig.charAt(index) != ')') {
paramtypes += objToAny(sig2type(tparams, skiptvs))
}
index += 1
@@ -791,9 +791,9 @@ abstract class ClassfileParser {
def sig2typeBounds(tparams: immutable.Map[Name, Symbol], skiptvs: Boolean): Type = {
val ts = new ListBuffer[Type]
- while (sig(index) == ':') {
+ while (sig.charAt(index) == ':') {
index += 1
- if (sig(index) != ':') // guard against empty class bound
+ if (sig.charAt(index) != ':') // guard against empty class bound
ts += objToAny(sig2type(tparams, skiptvs))
}
TypeBounds.upper(intersectionType(ts.toList, sym))
@@ -801,11 +801,11 @@ abstract class ClassfileParser {
var tparams = classTParams
val newTParams = new ListBuffer[Symbol]()
- if (sig(index) == '<') {
+ if (sig.charAt(index) == '<') {
assert(sym != null, sig)
index += 1
val start = index
- while (sig(index) != '>') {
+ while (sig.charAt(index) != '>') {
val tpname = subName(':'.==).toTypeName
val s = sym.newTypeParameter(tpname)
tparams = tparams + (tpname -> s)
@@ -813,7 +813,7 @@ abstract class ClassfileParser {
newTParams += s
}
index = start
- while (sig(index) != '>') {
+ while (sig.charAt(index) != '>') {
val tpname = subName(':'.==).toTypeName
val s = tparams(tpname)
s.setInfo(sig2typeBounds(tparams, false))
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index 95d0369707..7bd5f4caeb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -540,7 +540,7 @@ trait MethodSynthesis {
val ValDef(mods, name, _, _) = tree
val beans = beanAccessorsFromNames(tree)
if (beans.nonEmpty) {
- if (!name(0).isLetter)
+ if (!name.charAt(0).isLetter)
BeanPropertyAnnotationFieldWithoutLetterError(tree)
else if (mods.isPrivate) // avoids name clashes with private fields in traits
BeanPropertyAnnotationPrivateFieldError(tree)