summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-11-14 18:02:10 +0000
committerPaul Phillips <paulp@improving.org>2009-11-14 18:02:10 +0000
commit1cd31e2edd031c0d32266de54ef63ddb9233c047 (patch)
tree4659619c1b3532ce4b31b2f4b52f912d64dff188 /src
parent6c4064a77086ee82de861ec30dfd87fe120c6b0d (diff)
downloadscala-1cd31e2edd031c0d32266de54ef63ddb9233c047.tar.gz
scala-1cd31e2edd031c0d32266de54ef63ddb9233c047.tar.bz2
scala-1cd31e2edd031c0d32266de54ef63ddb9233c047.zip
Fixes and test cases for #2087 and #2400.
fixing a long-standing bug in fjbg and recompiling fjbg.jar, which had the side effect of revealing that the current fjbg jar had never been recompiled with target 1.5, so now it's smaller and (I imagine) faster.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala16
-rw-r--r--src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java2
-rw-r--r--src/library/scala/runtime/BoxesRunTime.java25
3 files changed, 14 insertions, 29 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
index 8ed2b04045..2d586ba7ea 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
@@ -162,28 +162,36 @@ trait TypeKinds { self: ICodes =>
case object BYTE extends TypeKind {
override def maxType(other: TypeKind): TypeKind =
other match {
- case BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE => other
+ case CHAR => INT
+ case BYTE | SHORT | INT | LONG | FLOAT | DOUBLE => other
case REFERENCE(NothingClass) => BYTE
case _ => abort("Uncomparable type kinds: BYTE with " + other)
}
}
+ /** Note that the max of Char/Byte and Char/Short is Int, because
+ * neither strictly encloses the other due to unsignedness.
+ * See ticket #2087 for a consequence.
+ */
+
/** A 2-byte signed integer */
case object SHORT extends TypeKind {
override def maxType(other: TypeKind): TypeKind =
other match {
- case BYTE | SHORT | CHAR => SHORT
+ case CHAR => INT
+ case BYTE | SHORT => SHORT
case REFERENCE(NothingClass) => SHORT
case INT | LONG | FLOAT | DOUBLE => other
case _ => abort("Uncomparable type kinds: SHORT with " + other)
}
}
- /** A 2-byte signed integer */
+ /** A 2-byte UNSIGNED integer */
case object CHAR extends TypeKind {
override def maxType(other: TypeKind): TypeKind =
other match {
- case BYTE | SHORT | CHAR => CHAR
+ case CHAR => CHAR
+ case BYTE | SHORT => INT
case REFERENCE(NothingClass) => CHAR
case INT | LONG | FLOAT | DOUBLE => other
case _ => abort("Uncomparable type kinds: CHAR with " + other)
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
index b8f29a6a2b..6ee18a59df 100644
--- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
+++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java
@@ -74,7 +74,7 @@ public class JExtendedCode extends JCode {
},
{
/* T_SHORT -> T_BOOLEAN */ forbidden,
- /* T_SHORT -> T_CHAR */ nothingToDo,
+ /* T_SHORT -> T_CHAR */ {JOpcode.I2C},
/* T_SHORT -> T_FLOAT */ {JOpcode.I2F},
/* T_SHORT -> T_DOUBLE */ {JOpcode.I2D},
/* T_SHORT -> T_BYTE */ {JOpcode.I2B},
diff --git a/src/library/scala/runtime/BoxesRunTime.java b/src/library/scala/runtime/BoxesRunTime.java
index 869eb375ac..b1cc464513 100644
--- a/src/library/scala/runtime/BoxesRunTime.java
+++ b/src/library/scala/runtime/BoxesRunTime.java
@@ -54,30 +54,7 @@ public class BoxesRunTime
}
public static Character boxToCharacter(char c) {
- // !!! Temporarily working around the "impossible" (?) fact that
- // c can have a negative value here. In any revision since r17461 try:
- // def foo = new (Short => Char) { def apply(x: Short) = x.toChar }
- // foo(-100)
- // and the -100 will get to Character, which will duly crash.
- // The bug was masked before because the Characters were created
- // with "new Character(c)", but now the static method uses the argument
- // as an index into a cache array, which can't be negative.
- //
- // It appears to be Short-specific; I can't get anything similar
- // out of Byte or Int.
- Character ret;
-
- // straightforward workarounds like bitmasking do not seem to
- // work here; is java optimizing out "impossible" tests/ops? I
- // don't know, but this is the safe way:
- try {
- ret = Character.valueOf(c);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- ret = new Character(c);
- }
-
- return ret;
+ return Character.valueOf(c);
}
public static Byte boxToByte(byte b) {