summaryrefslogtreecommitdiff
path: root/test/files/run/bcodeInlinerMixed/Test_2.scala
blob: db1ea14a8ff6435f29e5faa3fdfd23d9564f7eb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import scala.tools.partest.{BytecodeTest, ASMConverters}
import ASMConverters._

class D {
  // This is compiled with `A_1.class` on the classpath. When inlining `flop` (which invokes
  // `A_1.bar`), the inliner can check that the call to `A_1.bar` can be safely inlined into a
  // different classfile (D). See also comment in B_1.scala.
  def m(b: B) = b.flop
}

object Test extends BytecodeTest {
  def show: Unit = {
    val gIns = instructionsFromMethod(getMethod(loadClassNode("B"), "g"))
    val hIns = instructionsFromMethod(getMethod(loadClassNode("C"), "h"))
    for (i <- List(gIns, hIns)) {
      assert(i exists {
        // `flop` is not inlined
        case Invoke(_, _, "flop", "()I", _) => true
        case _ => false
      }, i mkString "\n")
    }

    val mIns = instructionsFromMethod(getMethod(loadClassNode("D"), "m"))
    assert(mIns exists {
      // `flop` is inlined, we get a call to `bar`
      case Invoke(_, _, "bar", "()I", _) => true
      case _ => false
    }, mIns mkString "\n")
  }
}