summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-06-13 10:37:16 +0000
committermihaylov <mihaylov@epfl.ch>2007-06-13 10:37:16 +0000
commit63d5f0c247513ba84512e25c838d073a62b9c507 (patch)
treed24bcdb0f7fab6c778f4d7c6ccc0368a363d5bcb /src
parent989c80bcade3c559e260de12337441902e551bba (diff)
downloadscala-63d5f0c247513ba84512e25c838d073a62b9c507.tar.gz
scala-63d5f0c247513ba84512e25c838d073a62b9c507.tar.bz2
scala-63d5f0c247513ba84512e25c838d073a62b9c507.zip
in BoxesUtility.unboxTo* cast directly to the e...
in BoxesUtility.unboxTo* cast directly to the expected box class before unboxing
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala6
-rw-r--r--src/library/scala/runtime/BoxesUtility.java28
2 files changed, 10 insertions, 24 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 09935b69e6..1b92462834 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -676,9 +676,9 @@ abstract class GenICode extends SubComponent {
if (settings.debug.value)
log("UNBOX : " + fun.symbol.fullNameString)
val ctx1 = genLoad(expr, ctx, toTypeKind(expr.tpe))
- assert(expectedType.isValueType)
- generatedType = expectedType
- ctx1.bb.emit(UNBOX(expectedType), expr.pos)
+ val boxType = toTypeKind(fun.symbol.owner.linkedClassOfClass.tpe)
+ generatedType = boxType
+ ctx1.bb.emit(UNBOX(boxType), expr.pos)
ctx1
case Apply(fun, args) =>
diff --git a/src/library/scala/runtime/BoxesUtility.java b/src/library/scala/runtime/BoxesUtility.java
index bd8446fd4d..bf065e7dbe 100644
--- a/src/library/scala/runtime/BoxesUtility.java
+++ b/src/library/scala/runtime/BoxesUtility.java
@@ -119,64 +119,50 @@ public class BoxesUtility {
public static char unboxToChar(Object c) {
if (c == null)
return 0;
- else if (c instanceof Character)
- return ((Character)c).charValue();
else
- return ((char)((Number)c).intValue());
+ return ((Character)c).charValue();
}
public static byte unboxToByte(Object b) {
if (b == null)
return 0;
- else if (b instanceof Number)
- return ((Number)b).byteValue();
else
- return ((byte)((Character)b).charValue());
+ return ((Byte)b).byteValue();
}
public static short unboxToShort(Object s) {
if (s == null)
return 0;
- else if (s instanceof Number)
- return ((Number)s).shortValue();
else
- return ((short)((Character)s).charValue());
+ return ((Short)s).shortValue();
}
public static int unboxToInt(Object i) {
if (i == null)
return 0;
- else if (i instanceof Number)
- return ((Number)i).intValue();
else
- return ((int)((Character)i).charValue());
+ return ((Integer)i).intValue();
}
public static long unboxToLong(Object l) {
if (l == null)
return 0;
- else if (l instanceof Number)
- return ((Number)l).longValue();
else
- return ((long)((Character)l).charValue());
+ return ((Long)l).longValue();
}
public static float unboxToFloat(Object f) {
if (f == null)
return 0.0f;
- else if (f instanceof Number)
- return ((Number)f).floatValue();
else
- return ((float)((Character)f).charValue());
+ return ((Float)f).floatValue();
}
public static double unboxToDouble(Object d) {
if (d == null)
return 0.0;
- else if (d instanceof Number)
- return ((Number)d).doubleValue();
else
- return ((double)((Character)d).charValue());
+ return ((Double)d).doubleValue();
}
}