Skip to content

Commit 0daf45d

Browse files
committed
Update BytecodeTest / CallGraphTest
1 parent 77dfcfe commit 0daf45d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

test/junit/scala/issues/BytecodeTest.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.junit.Assert._
1212
import scala.collection.JavaConverters._
1313
import scala.tools.asm.Opcodes
1414
import scala.tools.asm.tree.ClassNode
15+
import scala.tools.nsc.backend.jvm.opt.BytecodeUtils
1516
import scala.tools.partest.ASMConverters._
1617
import scala.tools.testing.ClearAfterClass
1718

@@ -221,7 +222,7 @@ class BytecodeTest extends ClearAfterClass {
221222

222223
def checkForwarder(c: ClassNode, target: String) = {
223224
val List(f) = findMethods(c, "f")
224-
assertSameCode(f, List(VarOp(ALOAD, 0), Invoke(INVOKESPECIAL, target, "f", "()I", false), Op(IRETURN)))
225+
assertSameCode(f, List(VarOp(ALOAD, 0), Invoke(INVOKESTATIC, target, "f", s"(L$target;)I", false), Op(IRETURN)))
225226
}
226227
}
227228

@@ -347,7 +348,7 @@ class BytecodeTest extends ClearAfterClass {
347348
def invocationReceivers(): Unit = {
348349
val List(c1, c2, t, u) = compileClasses(compiler)(invocationReceiversTestCode.definitions("Object"))
349350
// mixin forwarder in C1
350-
assertSameCode(getSingleMethod(c1, "clone"), List(VarOp(ALOAD, 0), Invoke(INVOKESPECIAL, "T", "clone", "()Ljava/lang/Object;", false), Op(ARETURN)))
351+
assertSameCode(getSingleMethod(c1, "clone"), List(VarOp(ALOAD, 0), Invoke(INVOKESTATIC, "T", "clone", "(LT;)Ljava/lang/Object;", false), Op(ARETURN)))
351352
assertInvoke(getSingleMethod(c1, "f1"), "T", "clone")
352353
assertInvoke(getSingleMethod(c1, "f2"), "T", "clone")
353354
assertInvoke(getSingleMethod(c1, "f3"), "C1", "clone")
@@ -356,8 +357,8 @@ class BytecodeTest extends ClearAfterClass {
356357
assertInvoke(getSingleMethod(c2, "f3"), "C1", "clone")
357358

358359
val List(c1b, c2b, tb, ub) = compileClasses(compiler)(invocationReceiversTestCode.definitions("String"))
359-
def ms(c: ClassNode, n: String) = c.methods.asScala.toList.filter(_.name == n)
360-
assert(ms(tb, "clone").length == 1)
360+
def ms(c: ClassNode, n: String) = c.methods.asScala.toList.filter(_.name == n).filterNot(BytecodeUtils.isStaticMethod)
361+
assert(ms(tb, "clone").length == 1, tb.methods.asScala.map(_.name))
361362
assert(ms(ub, "clone").isEmpty)
362363
val List(c1Clone) = ms(c1b, "clone")
363364
assertEquals(c1Clone.desc, "()Ljava/lang/Object;")

test/junit/scala/tools/nsc/backend/jvm/opt/CallGraphTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package opt
55
import org.junit.runner.RunWith
66
import org.junit.runners.JUnit4
77
import org.junit.Test
8+
89
import scala.collection.generic.Clearable
910
import scala.collection.immutable.IntMap
1011
import scala.tools.asm.Opcodes._
@@ -14,14 +15,13 @@ import scala.tools.asm.tree._
1415
import scala.tools.asm.tree.analysis._
1516
import scala.tools.nsc.reporters.StoreReporter
1617
import scala.tools.testing.AssertUtil._
17-
1818
import CodeGenTools._
1919
import scala.tools.partest.ASMConverters
2020
import ASMConverters._
2121
import AsmUtils._
2222
import BackendReporting._
23-
2423
import scala.collection.JavaConverters._
24+
import scala.tools.nsc.backend.jvm.opt.BytecodeUtils.isStaticMethod
2525
import scala.tools.testing.ClearAfterClass
2626

2727
object CallGraphTest extends ClearAfterClass.Clearable {
@@ -191,7 +191,7 @@ class CallGraphTest extends ClearAfterClass {
191191
val t3h = callIn("t3")
192192
assertEquals(t3h.argInfos.toList, List((1, FunctionLiteral)))
193193

194-
val selfSamCall = callIn("selfSamCall")
194+
val selfSamCall = callGraph.callsites.filter(_._1.name == "selfSamCall").filter(x => isStaticMethod(x._1)).values.head.values.head
195195
assertEquals(selfSamCall.argInfos.toList, List((0,ForwardedParam(0))))
196196
}
197197

0 commit comments

Comments
 (0)