summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-05-21 17:32:29 +0000
committerMartin Odersky <odersky@gmail.com>2008-05-21 17:32:29 +0000
commit96b80791737efd952383aba56ba69440e861647d (patch)
tree6df772e7a2d73ef0f934a18733486e06447d96c9 /src/compiler
parentb7efa99768e14c03df810b129f979ba61aba8e87 (diff)
downloadscala-96b80791737efd952383aba56ba69440e861647d.tar.gz
scala-96b80791737efd952383aba56ba69440e861647d.tar.bz2
scala-96b80791737efd952383aba56ba69440e861647d.zip
added tests; fixed #903; made Predef.Map covari...
added tests; fixed #903; made Predef.Map covariant in second parameter.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala10
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala20
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala5
3 files changed, 25 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index b6da9f9b1d..340f403f9f 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -446,15 +446,11 @@ trait Parsers extends NewScanners with MarkupParsers {
if (operator eq nme.ERROR) -1
else {
val firstCh = operator(0)
- if (operator(operator.length - 1) == '=' &&
- firstCh != '<' &&
- firstCh != '>' &&
- firstCh != '=' &&
- firstCh != '!')
- 0
- else if (((firstCh >= 'A') && (firstCh <= 'Z')) ||
+ if (((firstCh >= 'A') && (firstCh <= 'Z')) ||
((firstCh >= 'a') && (firstCh <= 'z')))
1
+ else if (nme.isOpAssignmentName(operator))
+ 0
else
firstCh match {
case '|' => 2
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 824323f20a..7ddc641f6f 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -97,7 +97,19 @@ trait StdNames {
def isSetterName(name: Name) = name.endsWith(SETTER_SUFFIX)
def isLocalDummyName(name: Name) = name.startsWith(LOCALDUMMY_PREFIX)
def isOpAssignmentName(name: Name) =
- name.endsWith(nme.EQL) && name != nme.EQ && !name.endsWith(nme.USCOREEQL)
+ name(name.length - 1) == '=' &&
+ isOperatorCharacter(name(0)) &&
+ name != EQraw && name != NEraw && name != LEraw && name != GEraw
+
+ def isOperatorCharacter(c: Char) = c match {
+ case '~' | '!' | '@' | '#' | '%' |
+ '^' | '*' | '+' | '-' | '<' |
+ '>' | '?' | ':' | '=' | '&' |
+ '|' | '\\'| '/' => true
+ case _ =>
+ val chtp = Character.getType(c)
+ chtp == Character.MATH_SYMBOL || chtp == Character.OTHER_SYMBOL
+ }
/** If `name' is an expandedName, the original name. Otherwise `name' itself.
* @see Symbol.expandedName
@@ -373,6 +385,12 @@ trait StdNames {
val UNARY_- = encode("unary_-")
val UNARY_! = encode("unary_!")
+ // unencoded comparisons
+ val EQraw = newTermName("==")
+ val NEraw = newTermName("!=")
+ val LEraw = newTermName("<=")
+ val GEraw = newTermName(">=")
+
// value-conversion methods
val toByte = newTermName("toByte")
val toShort = newTermName("toShort")
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index eb12867ea9..71a6ceeb34 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2595,12 +2595,13 @@ trait Typers { self: Analyzer =>
case ex: TypeError =>
fun match {
case Select(qual, name)
- if (mode & PATTERNmode) == 0 && nme.isOpAssignmentName(name) =>
+ if (mode & PATTERNmode) == 0 && nme.isOpAssignmentName(name.decode) =>
val qual1 = typedQualifier(qual)
if (treeInfo.isVariableOrGetter(qual1)) {
convertToAssignment(fun, qual1, name, args, ex)
} else {
- reportTypeError(fun.pos, ex)
+ if (qual1.symbol.isValue) error(tree.pos, "reassignment to val")
+ else reportTypeError(fun.pos, ex)
setError(tree)
}
case _ =>