diff options
-rw-r--r-- | src/cldc-library/scala/runtime/BoxesRunTime.java | 34 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxesRunTime.java | 34 | ||||
-rw-r--r-- | test/files/run/t0668.check | 0 | ||||
-rw-r--r-- | test/files/run/t0668.scala | 5 |
4 files changed, 73 insertions, 0 deletions
diff --git a/src/cldc-library/scala/runtime/BoxesRunTime.java b/src/cldc-library/scala/runtime/BoxesRunTime.java index 33c418381a..9374f6bce6 100644 --- a/src/cldc-library/scala/runtime/BoxesRunTime.java +++ b/src/cldc-library/scala/runtime/BoxesRunTime.java @@ -127,6 +127,39 @@ public class BoxesRunTime { /* UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING */ public static boolean unboxToBoolean(Object b) { + return b == null ? false : ((Boolean)b).booleanValue(); + } + + public static char unboxToChar(Object c) { + return c == null ? 0 : ((Character)c).charValue(); + } + + public static byte unboxToByte(Object b) { + return b == null ? 0 : ((Byte)b).byteValue(); + } + + public static short unboxToShort(Object s) { + return s == null ? 0 : ((Short)s).shortValue(); + } + + public static int unboxToInt(Object i) { + return i == null ? 0 : ((Integer)i).intValue(); + } + + public static long unboxToLong(Object l) { + return l == null ? 0 : ((Long)l).longValue(); + } + + public static float unboxToFloat(Object f) { + return f == null ? 0.0f : ((Float)f).floatValue(); + } + + public static double unboxToDouble(Object d) { + return d == null ? 0.0d : ((Double)d).doubleValue(); + } + + /* + public static boolean unboxToBoolean(Object b) { if (b == null) throw new ClassCastException("null is no Boolean value"); return ((Boolean)b).booleanValue(); @@ -161,6 +194,7 @@ public class BoxesRunTime { throw new ClassCastException("null is no Long value"); return ((Long)l).longValue(); } + */ /* COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON */ diff --git a/src/library/scala/runtime/BoxesRunTime.java b/src/library/scala/runtime/BoxesRunTime.java index 932c530901..a8e0549449 100644 --- a/src/library/scala/runtime/BoxesRunTime.java +++ b/src/library/scala/runtime/BoxesRunTime.java @@ -135,6 +135,39 @@ public class BoxesRunTime { /* UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING */ public static boolean unboxToBoolean(Object b) { + return b == null ? false : ((Boolean)b).booleanValue(); + } + + public static char unboxToChar(Object c) { + return c == null ? 0 : ((Character)c).charValue(); + } + + public static byte unboxToByte(Object b) { + return b == null ? 0 : ((Byte)b).byteValue(); + } + + public static short unboxToShort(Object s) { + return s == null ? 0 : ((Short)s).shortValue(); + } + + public static int unboxToInt(Object i) { + return i == null ? 0 : ((Integer)i).intValue(); + } + + public static long unboxToLong(Object l) { + return l == null ? 0 : ((Long)l).longValue(); + } + + public static float unboxToFloat(Object f) { + return f == null ? 0.0f : ((Float)f).floatValue(); + } + + public static double unboxToDouble(Object d) { + return d == null ? 0.0d : ((Double)d).doubleValue(); + } + + /* + public static boolean unboxToBoolean(Object b) { if (b == null) throw new ClassCastException("null is no Boolean value"); return ((Boolean)b).booleanValue(); @@ -181,6 +214,7 @@ public class BoxesRunTime { throw new ClassCastException("null is no Double value"); return ((Double)d).doubleValue(); } + */ /* COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON */ diff --git a/test/files/run/t0668.check b/test/files/run/t0668.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t0668.check diff --git a/test/files/run/t0668.scala b/test/files/run/t0668.scala new file mode 100644 index 0000000000..2f1eaba0d9 --- /dev/null +++ b/test/files/run/t0668.scala @@ -0,0 +1,5 @@ +object Test extends Application { + val ints: Array[Int] = Array(1, 2, 3) + ints.toArray +} + |