summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-02-22 19:39:24 -0800
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-02-22 19:39:24 -0800
commit6e2f0fa09dc7f264865433865238661657facf09 (patch)
tree7a7a2fa843c1844351efe2f10fe80282b0de7fde /test
parent71a7739fc3e81c1642f358372febb91744c70cb4 (diff)
parent62fcd3d922056407703ac3363b897f82980b0926 (diff)
downloadscala-6e2f0fa09dc7f264865433865238661657facf09.tar.gz
scala-6e2f0fa09dc7f264865433865238661657facf09.tar.bz2
scala-6e2f0fa09dc7f264865433865238661657facf09.zip
Merge pull request #2147 from JamesIry/master_SI-7015
SI-7015 Removes redundant aconst_null; pop; aconst_null creation
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t7015.check11
-rw-r--r--test/files/run/t7015.scala49
2 files changed, 60 insertions, 0 deletions
diff --git a/test/files/run/t7015.check b/test/files/run/t7015.check
new file mode 100644
index 0000000000..7651fe06b0
--- /dev/null
+++ b/test/files/run/t7015.check
@@ -0,0 +1,11 @@
+Method returns Null type: null
+Method takes non Null type: null
+call through method null
+call through bridge null
+fetch field: null
+fetch field on companion: null
+fetch local: null
+fetch array element: null
+method that takes object: null
+method that takes anyref: null
+method that takes any: null
diff --git a/test/files/run/t7015.scala b/test/files/run/t7015.scala
new file mode 100644
index 0000000000..37a73a9fc4
--- /dev/null
+++ b/test/files/run/t7015.scala
@@ -0,0 +1,49 @@
+object Test {
+ def main(args : Array[String]) : Unit = {
+ println(s"Method returns Null type: $f")
+ println(s"Method takes non Null type: ${g(null)}")
+
+ // pass things through the g function because it expects
+ // a string. If we haven't adapted properly then we'll
+ // get verify errors
+ val b = new B
+ println(s"call through method ${g(b.f(null))}")
+ println(s"call through bridge ${g((b: A).f(null))}")
+
+ println(s"fetch field: ${g(b.nullField)}")
+ println(s"fetch field on companion: ${g(B.nullCompanionField)}")
+
+ val x = f
+ println(s"fetch local: ${g(x)}")
+
+ val nulls = Array(f, f, f)
+ println(s"fetch array element: ${g(nulls(0))}")
+
+ println(s"method that takes object: ${q(f)}")
+ println(s"method that takes anyref: ${r(f)}")
+ println(s"method that takes any: ${s(f)}")
+ }
+
+ def f: Null = null
+
+ def g(x: String) = x
+
+ def q(x: java.lang.Object) = x
+ def r(x: AnyRef) = x
+ def s(x: Any) = x
+}
+
+abstract class A {
+ def f(x: String): String
+}
+
+class B extends A {
+ val nullField = null
+
+ // this forces a bridge method because the return type is different
+ override def f(x: String) : Null = null
+}
+
+object B {
+ val nullCompanionField = null
+} \ No newline at end of file