summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2005-11-09 11:32:07 +0000
committerIulian Dragos <jaguarul@gmail.com>2005-11-09 11:32:07 +0000
commit071be391c1cf77c3e22c33aad8a2e783c59d1574 (patch)
tree5219671e04bd5ff061e6b824387e28a741d2ab47
parent90b93c790c6687ae34d3519f4b1fb6dd91007e9f (diff)
downloadscala-071be391c1cf77c3e22c33aad8a2e783c59d1574.tar.gz
scala-071be391c1cf77c3e22c33aad8a2e783c59d1574.tar.bz2
scala-071be391c1cf77c3e22c33aad8a2e783c59d1574.zip
Check for repetitive methods/fields
-rw-r--r--sources/scala/tools/nsc/backend/icode/Checkers.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/sources/scala/tools/nsc/backend/icode/Checkers.scala b/sources/scala/tools/nsc/backend/icode/Checkers.scala
index fdd8912d84..8c3c80756a 100644
--- a/sources/scala/tools/nsc/backend/icode/Checkers.scala
+++ b/sources/scala/tools/nsc/backend/icode/Checkers.scala
@@ -65,9 +65,28 @@ abstract class Checkers {
def check(cls: IClass): Unit = {
log("Checking class " + cls);
clasz = cls;
+
+ for (val f1 <- cls.fields; val f2 <- cls.fields; f1 ne f2)
+ if (f1.symbol.name == f2.symbol.name)
+ Checkers.this.global.error("Repetitive field name: " +
+ f1.symbol.fullNameString);
+
+ for (val m1 <- cls.methods; val m2 <- cls.methods; m1 ne m2)
+ if (m1.symbol.name == m2.symbol.name &&
+ m1.symbol.tpe =:= m2.symbol.tpe)
+ Checkers.this.global.error("Repetitive method: " +
+ m1.symbol.fullNameString);
clasz.methods.foreach(check);
}
+ /** Apply the give funtion to each pair of the cartesian product of
+ * l1 x l2.
+ */
+ def pairwise[a](l1: List[a], l2: List[a])(f: (a, a) => Unit) =
+ l1 foreach { x =>
+ l2 foreach { y => f(x, y) }
+ }
+
def check(m: IMethod): Unit = {
log("Checking method " + m);
method = m;