summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-05-13 16:37:33 +0000
committerMartin Odersky <odersky@gmail.com>2008-05-13 16:37:33 +0000
commit7c319c48ea283f2400aabffd31f0b37820f7697a (patch)
tree5e9fac636619f8e068f26e5c215cd6a3fb1ce322 /src/compiler
parentad903380ca09444fa11ae274e9569a46f3c66f9b (diff)
downloadscala-7c319c48ea283f2400aabffd31f0b37820f7697a.tar.gz
scala-7c319c48ea283f2400aabffd31f0b37820f7697a.tar.bz2
scala-7c319c48ea283f2400aabffd31f0b37820f7697a.zip
1. Removed StdNames.EQEQ, plecae by StdNames.EQ
2. Changed priority of assignment operators to be the same as = 3. Changed complexity measure for implicit divergence detection.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/matching/CodeFactory.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala16
6 files changed, 22 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 78af57b191..b5e1b33853 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -446,7 +446,13 @@ trait Parsers extends NewScanners with MarkupParsers {
if (operator eq nme.ERROR) -1
else {
val firstCh = operator(0)
- if (((firstCh >= 'A') && (firstCh <= 'Z')) ||
+ if (operator(operator.length - 1) == '=' &&
+ firstCh != '<' &&
+ firstCh != '>' &&
+ firstCh != '=' &&
+ firstCh != '!')
+ 0
+ else if (((firstCh >= 'A') && (firstCh <= 'Z')) ||
((firstCh >= 'a') && (firstCh <= 'z')))
1
else
diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
index 3d2d64051f..5b31e4c47e 100644
--- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
+++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
@@ -177,7 +177,7 @@ trait CodeFactory {
}
final def Equals(left: Tree, right: Tree): Tree =
- Apply(Select(left, nme.EQEQ), List(right))
+ Apply(Select(left, nme.EQ), List(right))
final def Eq(left: Tree, right: Tree): Tree =
Apply(Select(left, nme.eq), List(right))
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index c868907a55..8cb2955ac6 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -74,7 +74,7 @@ trait Definitions {
var IntClass: Symbol = _
def Int_Or = definitions.getMember(definitions.IntClass, nme.OR)
def Int_And = definitions.getMember(definitions.IntClass, nme.AND)
- def Int_== = definitions.getMember(definitions.IntClass, nme.EQEQ)
+ def Int_== = definitions.getMember(definitions.IntClass, nme.EQ)
var LongClass: Symbol = _
var FloatClass: Symbol = _
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 3d39632ac9..824323f20a 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -97,7 +97,7 @@ 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.EQEQ && !name.endsWith(nme.USCOREEQL)
+ name.endsWith(nme.EQL) && name != nme.EQ && !name.endsWith(nme.USCOREEQL)
/** If `name' is an expandedName, the original name. Otherwise `name' itself.
* @see Symbol.expandedName
@@ -193,7 +193,6 @@ trait StdNames {
val PLUS = encode("+")
val PLUSPLUS = encode("++")
val TILDE = encode("~")
- val EQEQ = encode("==")
val BANG = encode("!")
val BANGEQ = encode("!=")
val BARBAR = encode("||")
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 962f749591..51fa7f9b00 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -160,7 +160,7 @@ trait SyntheticMethods { self: Analyzer =>
guards += Apply(
Select(
Ident(name),
- if (isVarArg) nme.sameElements else nme.EQEQ),
+ if (isVarArg) nme.sameElements else nme.EQ),
List(Ident(acc)))
Bind(name,
if (isVarArg) Star(Ident(nme.WILDCARD))
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 4f1c9e3a7e..027aa4ff7e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3371,11 +3371,17 @@ trait Typers { self: Analyzer =>
case _ => tp
}
def sum(xs: List[Int]) = (0 /: xs)(_ + _)
- def complexity(tp: Type): Int = tp match {
- case SingleType(pre, sym) => complexity(pre) + 1
- case TypeRef(pre, sym, args) => complexity(pre) + sum(args map complexity) + 1
- case RefinedType(parents, _) => sum(parents map complexity) + 1
- case _ => 1
+ def complexity(tp: Type): Int = tp.normalize match {
+ case NoPrefix =>
+ 0
+ case SingleType(pre, sym) =>
+ if (sym.isPackage) 0 else complexity(tp.widen)
+ case TypeRef(pre, sym, args) =>
+ complexity(pre) + sum(args map complexity) + 1
+ case RefinedType(parents, _) =>
+ sum(parents map complexity) + 1
+ case _ =>
+ 1
}
def overlaps(tp1: Type, tp2: Type): Boolean = (tp1, tp2) match {
case (RefinedType(parents, _), _) => parents exists (overlaps(_, tp2))