diff options
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t6719.check | 1 | ||||
-rw-r--r-- | test/files/run/t6719.scala | 8 | ||||
-rw-r--r-- | test/files/run/t7852.check | 0 | ||||
-rw-r--r-- | test/files/run/t7852.flags | 1 | ||||
-rw-r--r-- | test/files/run/t7852.scala | 39 |
5 files changed, 49 insertions, 0 deletions
diff --git a/test/files/run/t6719.check b/test/files/run/t6719.check new file mode 100644 index 0000000000..6a452c185a --- /dev/null +++ b/test/files/run/t6719.check @@ -0,0 +1 @@ +() diff --git a/test/files/run/t6719.scala b/test/files/run/t6719.scala new file mode 100644 index 0000000000..847929a95d --- /dev/null +++ b/test/files/run/t6719.scala @@ -0,0 +1,8 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox, ToolBoxError} +object Test extends App { + val tb = cm.mkToolBox() + val tree = tb.parse("(); val res = 0") + println(tb.eval(tree)) +}
\ No newline at end of file diff --git a/test/files/run/t7852.check b/test/files/run/t7852.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7852.check diff --git a/test/files/run/t7852.flags b/test/files/run/t7852.flags new file mode 100644 index 0000000000..f6262fd3e0 --- /dev/null +++ b/test/files/run/t7852.flags @@ -0,0 +1 @@ +-Ynooptimise diff --git a/test/files/run/t7852.scala b/test/files/run/t7852.scala new file mode 100644 index 0000000000..c93db718fd --- /dev/null +++ b/test/files/run/t7852.scala @@ -0,0 +1,39 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import scala.tools.asm.util._ +import scala.tools.nsc.util.stringFromWriter +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + val nullChecks = Set(asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL) + + def show: Unit = { + def test(methodName: String, expected: Int) { + val classNode = loadClassNode("Lean") + val methodNode = getMethod(classNode, methodName) + val got = countNullChecks(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got comparisons") + } + test("string", expected = 0) + test("module", expected = 0) + test("moduleIndirect", expected = 2) + } + + def countNullChecks(insnList: asm.tree.InsnList): Int = + insnList.iterator.asScala.map(_.getOpcode).count(nullChecks) +} + +class Lean { + def string { + "" == toString + } + + def module { + Nil == (toString: Any) + } + + def moduleIndirect { + val n: Nil.type = null + n == (toString: Any) // still need null checks here. + } +} |