diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-11 20:08:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-11 20:08:47 +0000 |
commit | 566fefb05abe31e90f765d1fb0a89b264302d9ce (patch) | |
tree | 28be1b3d6c4b862ff9a24b6dd665cbb8df1b68a9 /test/files | |
parent | 5f40fe0456238a8c58d05e58cd61a960f9a107a7 (diff) | |
download | scala-566fefb05abe31e90f765d1fb0a89b264302d9ce.tar.gz scala-566fefb05abe31e90f765d1fb0a89b264302d9ce.tar.bz2 scala-566fefb05abe31e90f765d1fb0a89b264302d9ce.zip |
In r22807 an optimization was added to remove B...
In r22807 an optimization was added to remove Box(Unbox(x))
combinations. It turns out that without this in place, an expression
like "x".asInstanceOf[Int] will no longer throw an exception. Refined
the optimization. Closes #4148, review by dragos.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/bug4148.check | 3 | ||||
-rw-r--r-- | test/files/run/bug4148.scala | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/test/files/run/bug4148.check b/test/files/run/bug4148.check new file mode 100644 index 0000000000..544b0d19d1 --- /dev/null +++ b/test/files/run/bug4148.check @@ -0,0 +1,3 @@ +cce1 +5 +100 diff --git a/test/files/run/bug4148.scala b/test/files/run/bug4148.scala new file mode 100644 index 0000000000..a7d181268d --- /dev/null +++ b/test/files/run/bug4148.scala @@ -0,0 +1,9 @@ +object Test { + val x1 = try { "aaa".asInstanceOf[Int] } catch { case _ => "cce1" } + val x2 = try { (5: Any).asInstanceOf[Int] } catch { case _ => "cce2" } + val x3 = try { (new java.lang.Short(100.toShort).asInstanceOf[Int]) } catch { case _ => "cce3" } + + def main(args: Array[String]): Unit = { + List(x1, x2, x3) foreach println + } +} |