summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2005-01-17 14:50:31 +0000
committerschinz <schinz@epfl.ch>2005-01-17 14:50:31 +0000
commit71010e2f3f5197e0987c854f8c23238380142d61 (patch)
treee5b0c4826867bdcff2bd326cabde3239e630b7c1
parent2c5022f9da8c3b0edd500b36dbaee97acb6c8929 (diff)
downloadscala-71010e2f3f5197e0987c854f8c23238380142d61.tar.gz
scala-71010e2f3f5197e0987c854f8c23238380142d61.tar.bz2
scala-71010e2f3f5197e0987c854f8c23238380142d61.zip
- added a few "special" types (All, AllRef, etc.)
-rw-r--r--sources/scala/Type.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/sources/scala/Type.java b/sources/scala/Type.java
index afaa44239f..c61346cb64 100644
--- a/sources/scala/Type.java
+++ b/sources/scala/Type.java
@@ -20,6 +20,11 @@ import scala.runtime.types.TypeFloat;
import scala.runtime.types.TypeInt;
import scala.runtime.types.TypeLong;
import scala.runtime.types.TypeShort;
+import scala.runtime.types.TypeUnit;
+import scala.runtime.types.TypeAll;
+import scala.runtime.types.TypeAllRef;
+import scala.runtime.types.TypeAny;
+import scala.runtime.types.TypeAnyVal;
import scala.runtime.FNV_Hash;
import scala.runtime.PearsonHash;
@@ -53,6 +58,11 @@ abstract public class Type {
return (that instanceof Type) && this.isSameAs((Type)that);
}
+ public int hashCode() {
+ throw new Error("missing hashCode implementation in class "
+ + this.getClass());
+ }
+
/**
* Check that the given object can be cast to this type, and throw
* an exception if this is not possible (implement Scala's
@@ -60,11 +70,11 @@ abstract public class Type {
*/
public Object checkCastability(Object o) {
if (! (o == null || isInstance(o)))
- throw new ClassCastException(this.toString());
+ throw new ClassCastException("\n" + ((ScalaObject)o).getType() + "\n" + this.toString());
return o;
}
- // Basic types
+ // Value types
public static final TypeDouble Double = new TypeDouble();
public static final TypeFloat Float = new TypeFloat();
public static final TypeLong Long = new TypeLong();
@@ -73,6 +83,23 @@ 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 final TypeUnit Unit = new TypeUnit();
+
+ // "Special" types
+ public static final TypeAny Any = new TypeAny();
+ public static final TypeAnyVal AnyVal = new TypeAnyVal();
+ public static final TypeAllRef AllRef = new TypeAllRef();
+ public static final TypeAll All = new TypeAll();
+
+ public static boolean isSameAs(Type[] these, Type[] those) {
+ if (these.length != those.length)
+ return false;
+ for (int i = 0; i < these.length; ++i) {
+ if (!these[i].isSameAs(those[i]))
+ return false;
+ }
+ return true;
+ }
public static int hashCode(Type[] types) {
final int len = types.length;