diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-25 14:16:27 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-01-31 11:00:43 -0800 |
commit | 71ea3e8278aad030cbe8c9093fe49790a4e419cb (patch) | |
tree | 49d19f3ed008ade9245545a3991b244859249bd6 /test/files/jvm/patmat_opt_no_nullcheck/test.scala | |
parent | 62b37dd9a87afd17a67752c6c1b174987817b3e9 (diff) | |
download | scala-71ea3e8278aad030cbe8c9093fe49790a4e419cb.tar.gz scala-71ea3e8278aad030cbe8c9093fe49790a4e419cb.tar.bz2 scala-71ea3e8278aad030cbe8c9093fe49790a4e419cb.zip |
no null check for type-tested unapply arg
pattern matching on case classes where pattern
is not known to be a subclass of the unapply's argument type
used to result in code like:
```
if (x1.isInstanceOf[Foo]) {
val x2 = x1.asInstanceOf[Foo]
if (x2 != null) { // redundant
...
}
}
```
this wastes byte code on the redundant null check
with this patch, when previous type tests imply
the variable cannot be null, there's no null check
Diffstat (limited to 'test/files/jvm/patmat_opt_no_nullcheck/test.scala')
-rw-r--r-- | test/files/jvm/patmat_opt_no_nullcheck/test.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/jvm/patmat_opt_no_nullcheck/test.scala b/test/files/jvm/patmat_opt_no_nullcheck/test.scala new file mode 100644 index 0000000000..2927e763d5 --- /dev/null +++ b/test/files/jvm/patmat_opt_no_nullcheck/test.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.BytecodeTest + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("SameBytecode") + sameBytecode(getMethod(classNode, "a"), getMethod(classNode, "b")) + } +} |