summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2004-10-26 13:14:25 +0000
committerschinz <schinz@epfl.ch>2004-10-26 13:14:25 +0000
commit5e1103c409f75e4caff4dca2e1b8e05888fa2c33 (patch)
tree818cd906b32604df4a07cff30456022a19f5f01f /sources
parent35612e02fca0664f7cb70ff785e42ee69cc19c17 (diff)
downloadscala-5e1103c409f75e4caff4dca2e1b8e05888fa2c33.tar.gz
scala-5e1103c409f75e4caff4dca2e1b8e05888fa2c33.tar.bz2
scala-5e1103c409f75e4caff4dca2e1b8e05888fa2c33.zip
- introduced equals method
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/Type.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/sources/scala/Type.java b/sources/scala/Type.java
index d1c0dcbf10..afaa44239f 100644
--- a/sources/scala/Type.java
+++ b/sources/scala/Type.java
@@ -21,6 +21,9 @@ import scala.runtime.types.TypeInt;
import scala.runtime.types.TypeLong;
import scala.runtime.types.TypeShort;
+import scala.runtime.FNV_Hash;
+import scala.runtime.PearsonHash;
+
/**
* Run-time types for Scala.
*
@@ -43,8 +46,13 @@ abstract public class Type {
*/
abstract public boolean isInstance(Object o);
+ abstract public boolean isSameAs(Type that);
abstract public boolean isSubType(Type that);
+ public boolean equals(Object that) {
+ return (that instanceof Type) && this.isSameAs((Type)that);
+ }
+
/**
* Check that the given object can be cast to this type, and throw
* an exception if this is not possible (implement Scala's
@@ -65,4 +73,14 @@ abstract public class Type {
public static final TypeChar Char = new TypeChar();
public static final TypeByte Byte = new TypeByte();
public static final TypeBoolean Boolean = new TypeBoolean();
+
+ public static int hashCode(Type[] types) {
+ final int len = types.length;
+
+ int h = FNV_Hash.INIT;
+ for (int i = 0; i < len; ++i)
+ h = FNV_Hash.hashStep(h, PearsonHash.hash8(types[i].hashCode()));
+
+ return h;
+ }
}