@@ -323,7 +323,7 @@ class InlinerTest extends ClearAfterClass {
323
323
| def g(t: T) = t.f
324
324
|}
325
325
""" .stripMargin
326
- val List (c, t, tClass ) = compile(code)
326
+ val List (c, t) = compile(code)
327
327
assertNoInvoke(getSingleMethod(c, " g" ))
328
328
}
329
329
@@ -451,7 +451,7 @@ class InlinerTest extends ClearAfterClass {
451
451
| def t2(c: C) = c.f
452
452
|}
453
453
""" .stripMargin
454
- val List (c, t, tClass ) = compile(code)
454
+ val List (c, t) = compile(code)
455
455
// both are just `return 1`, no more calls
456
456
assertNoInvoke(getSingleMethod(c, " t1" ))
457
457
assertNoInvoke(getSingleMethod(c, " t2" ))
@@ -465,7 +465,7 @@ class InlinerTest extends ClearAfterClass {
465
465
|}
466
466
|class C extends T
467
467
""" .stripMargin
468
- val List (c, t, tClass ) = compile(code)
468
+ val List (c, t) = compile(code)
469
469
// the static implementation method is inlined into the mixin, so there's no invocation in the mixin
470
470
assertNoInvoke(getSingleMethod(c, " f" ))
471
471
}
@@ -484,7 +484,7 @@ class InlinerTest extends ClearAfterClass {
484
484
| def t2 = g
485
485
|}
486
486
""" .stripMargin
487
- val List (c, t, tClass, u, uClass ) = compile(code)
487
+ val List (c, t, u ) = compile(code)
488
488
assertNoInvoke(getSingleMethod(c, " t1" ))
489
489
assertNoInvoke(getSingleMethod(c, " t2" ))
490
490
}
@@ -504,7 +504,7 @@ class InlinerTest extends ClearAfterClass {
504
504
" C::f()I is annotated @inline but cannot be inlined: the method is not final and may be overridden" ,
505
505
" T::f()I is annotated @inline but cannot be inlined: the method is not final and may be overridden" )
506
506
var count = 0
507
- val List (c, t, tClass ) = compile(code, allowMessage = i => {count += 1 ; warns.exists(i.msg contains _)})
507
+ val List (c, t) = compile(code, allowMessage = i => {count += 1 ; warns.exists(i.msg contains _)})
508
508
assert(count == 2 , count)
509
509
assertInvoke(getSingleMethod(c, " t1" ), " T" , " f" )
510
510
assertInvoke(getSingleMethod(c, " t2" ), " C" , " f" )
@@ -520,7 +520,7 @@ class InlinerTest extends ClearAfterClass {
520
520
| def t1(t: T) = t.f
521
521
|}
522
522
""" .stripMargin
523
- val List (c, t, tClass ) = compile(code)
523
+ val List (c, t) = compile(code)
524
524
assertNoInvoke(getSingleMethod(c, " t1" ))
525
525
}
526
526
@@ -532,7 +532,7 @@ class InlinerTest extends ClearAfterClass {
532
532
|}
533
533
|object O extends T {
534
534
| @inline def g = 1
535
- | // mixin generates `def f = T$class.f(this) `, which is inlined here (we get ICONST_0)
535
+ | // mixin generates `def f = super[T].f `, which is inlined here (we get ICONST_0)
536
536
|}
537
537
|class C {
538
538
| def t1 = O.f // the mixin method of O is inlined, so we directly get the ICONST_0
@@ -542,7 +542,7 @@ class InlinerTest extends ClearAfterClass {
542
542
""" .stripMargin
543
543
val warn = " T::f()I is annotated @inline but cannot be inlined: the method is not final and may be overridden"
544
544
var count = 0
545
- val List (c, oMirror, oModule, t, tClass ) = compile(code, allowMessage = i => {count += 1 ; i.msg contains warn})
545
+ val List (c, oMirror, oModule, t) = compile(code, allowMessage = i => {count += 1 ; i.msg contains warn})
546
546
assert(count == 1 , count)
547
547
548
548
assertNoInvoke(getSingleMethod(oModule, " f" ))
@@ -561,21 +561,19 @@ class InlinerTest extends ClearAfterClass {
561
561
|}
562
562
|trait Assembly extends T {
563
563
| @inline final def g = 1
564
- | @inline final def n = m // inlined. (*)
565
- | // (*) the declaration class of m is T. the signature of T$class.m is m(LAssembly;)I. so we need the self type to build the
566
- | // signature. then we can look up the MethodNode of T$class.m and then rewrite the INVOKEINTERFACE to INVOKESTATIC.
564
+ | @inline final def n = m // inlined (m is final)
567
565
|}
568
566
|class C {
569
- | def t1(a: Assembly) = a.f // like above, decl class is T, need self-type of T to rewrite the interface call to static.
567
+ | def t1(a: Assembly) = a.f // inlined (f is final)
570
568
| def t2(a: Assembly) = a.n
571
569
|}
572
570
""" .stripMargin
573
571
574
- val List (assembly, assemblyClass, c, t, tClass ) = compile(code)
572
+ val List (assembly, c, t) = compile(code)
575
573
576
- assertNoInvoke(getSingleMethod(tClass , " f" ))
574
+ assertNoInvoke(getSingleMethod(t , " f" ))
577
575
578
- assertNoInvoke(getSingleMethod(assemblyClass , " n" ))
576
+ assertNoInvoke(getSingleMethod(assembly , " n" ))
579
577
580
578
assertNoInvoke(getSingleMethod(c, " t1" ))
581
579
assertNoInvoke(getSingleMethod(c, " t2" ))
@@ -610,30 +608,30 @@ class InlinerTest extends ClearAfterClass {
610
608
val code =
611
609
""" trait T1 {
612
610
| @inline def f: Int = 0
613
- | @inline def g1 = f // not inlined: f not final, so T1$class.g1 has an interface call T1.f
611
+ | @inline def g1 = f // not inlined: f not final
614
612
|}
615
613
|
616
- |// erased self-type (used in impl class for `self` parameter) : T1
614
+ |// erased self-type: T1
617
615
|trait T2a { self: T1 with T2a =>
618
616
| @inline override final def f = 1
619
- | @inline def g2a = f // inlined: resolved as T2a.f, which is re-written to T2a$class.f, so T2a$class.g2a has ICONST_1
617
+ | @inline def g2a = f // inlined: resolved as T2a.f
620
618
|}
621
619
|
622
620
|final class Ca extends T1 with T2a {
623
- | // mixin generates accessors like `def g1 = T1$class .g1`, the impl class method call is inlined into the accessor.
621
+ | // mixin generates accessors like `def g1 = super[T1] .g1`, the impl super call is inlined into the accessor.
624
622
|
625
623
| def m1a = g1 // call to accessor, inlined, we get the interface call T1.f
626
624
| def m2a = g2a // call to accessor, inlined, we get ICONST_1
627
625
| def m3a = f // call to accessor, inlined, we get ICONST_1
628
626
|
629
- | def m4a(t: T1) = t.f // T1.f is not final, so not inlined, interface call to T1.f
630
- | def m5a(t: T2a) = t.f // re-written to T2a$class.f, inlined, ICONST_1
627
+ | def m4a(t: T1) = t.f // T1.f is not final, so not inlined, we get an interface call T1.f
628
+ | def m5a(t: T2a) = t.f // inlined, we get ICONST_1
631
629
|}
632
630
|
633
631
|// erased self-type: T2b
634
632
|trait T2b { self: T2b with T1 =>
635
633
| @inline override final def f = 1
636
- | @inline def g2b = f // not inlined: resolved as T1.f, so T2b$class.g2b has an interface call T1.f
634
+ | @inline def g2b = f // not inlined: resolved as T1.f, we get an interface call T1.f
637
635
|}
638
636
|
639
637
|final class Cb extends T1 with T2b {
@@ -642,23 +640,17 @@ class InlinerTest extends ClearAfterClass {
642
640
| def m3b = f // inlined, we get ICONST_1
643
641
|
644
642
| def m4b(t: T1) = t.f // T1.f is not final, so not inlined, interface call to T1.f
645
- | def m5b(t: T2b) = t.f // re-written to T2b$class.f, inlined, ICONST_1
643
+ | def m5b(t: T2b) = t.f // inlined, ICONST_1
646
644
|}
647
645
""" .stripMargin
648
646
649
647
val warning = " T1::f()I is annotated @inline but cannot be inlined: the method is not final and may be overridden"
650
648
var count = 0
651
- val List (ca, cb, t1, t1C, t2a, t2aC, t2b, t2bC ) = compile(code, allowMessage = i => {count += 1 ; i.msg contains warning})
649
+ val List (ca, cb, t1, t2a, t2b) = compile(code, allowMessage = i => {count += 1 ; i.msg contains warning})
652
650
assert(count == 4 , count) // see comments, f is not inlined 4 times
653
651
654
- val t2aCfDesc = t2aC.methods.asScala.find(_.name == " f" ).get.desc
655
- assert(t2aCfDesc == " (LT1;)I" , t2aCfDesc) // self-type of T2a is T1
656
-
657
- val t2bCfDesc = t2bC.methods.asScala.find(_.name == " f" ).get.desc
658
- assert(t2bCfDesc == " (LT2b;)I" , t2bCfDesc) // self-type of T2b is T2b
659
-
660
- assertNoInvoke(getSingleMethod(t2aC, " g2a" ))
661
- assertInvoke(getSingleMethod(t2bC, " g2b" ), " T1" , " f" )
652
+ assertNoInvoke(getSingleMethod(t2a, " g2a" ))
653
+ assertInvoke(getSingleMethod(t2b, " g2b" ), " T1" , " f" )
662
654
663
655
assertInvoke(getSingleMethod(ca, " m1a" ), " T1" , " f" )
664
656
assertNoInvoke(getSingleMethod(ca, " m2a" )) // no invoke, see comment on def g2a
@@ -695,14 +687,13 @@ class InlinerTest extends ClearAfterClass {
695
687
val code =
696
688
""" class C {
697
689
| trait T { @inline final def f = 1 }
698
- | class D extends T{
690
+ | class D extends T {
699
691
| def m(t: T) = t.f
700
692
| }
701
- |
702
693
| def m(d: D) = d.f
703
694
|}
704
695
""" .stripMargin
705
- val List (c, d, t, tC ) = compile(code)
696
+ val List (c, d, t) = compile(code)
706
697
assertNoInvoke(getSingleMethod(d, " m" ))
707
698
assertNoInvoke(getSingleMethod(c, " m" ))
708
699
}
@@ -717,9 +708,9 @@ class InlinerTest extends ClearAfterClass {
717
708
| def t2(t: T) = t.f(2)
718
709
|}
719
710
""" .stripMargin
720
- val List (c, t, tc ) = compile(code)
721
- val t1 = getSingleMethod(tc , " t1" )
722
- val t2 = getSingleMethod(tc , " t2" )
711
+ val List (c, t) = compile(code)
712
+ val t1 = getSingleMethod(t , " t1" )
713
+ val t2 = getSingleMethod(t , " t2" )
723
714
val cast = TypeOp (CHECKCAST , " C" )
724
715
Set (t1, t2).foreach(m => assert(m.instructions.contains(cast), m.instructions))
725
716
}
@@ -766,8 +757,8 @@ class InlinerTest extends ClearAfterClass {
766
757
| final val d = 3
767
758
| final val d1: Int = 3
768
759
|
769
- | @noinline def f = 5 // re-written to T$class
770
- | @noinline final def g = 6 // re-written
760
+ | @noinline def f = 5
761
+ | @noinline final def g = 6
771
762
|
772
763
| @noinline def h: Int
773
764
| @inline def i: Int
@@ -780,8 +771,8 @@ class InlinerTest extends ClearAfterClass {
780
771
| final val d = 3
781
772
| final val d1: Int = 3
782
773
|
783
- | @noinline def f = 5 // not re-written (not final)
784
- | @noinline final def g = 6 // re-written
774
+ | @noinline def f = 5
775
+ | @noinline final def g = 6
785
776
|
786
777
| @noinline def h: Int
787
778
| @inline def i: Int
@@ -798,7 +789,7 @@ class InlinerTest extends ClearAfterClass {
798
789
|}
799
790
""" .stripMargin
800
791
801
- val List (c, t, tClass, u, uClass ) = compile(code, allowMessage = _.msg contains " i()I is annotated @inline but cannot be inlined" )
792
+ val List (c, t, u ) = compile(code, allowMessage = _.msg contains " i()I is annotated @inline but cannot be inlined" )
802
793
val m1 = getSingleMethod(c, " m1" )
803
794
assertInvoke(m1, " T" , " a" )
804
795
assertInvoke(m1, " T" , " b" )
@@ -807,8 +798,8 @@ class InlinerTest extends ClearAfterClass {
807
798
assertNoInvoke(getSingleMethod(c, " m2" ))
808
799
809
800
val m3 = getSingleMethod(c, " m3" )
810
- assertInvoke(m3, " T$class " , " f" )
811
- assertInvoke(m3, " T$class " , " g" )
801
+ assertInvoke(m3, " T" , " f" )
802
+ assertInvoke(m3, " T" , " g" )
812
803
assertInvoke(m3, " T" , " h" )
813
804
assertInvoke(m3, " T" , " i" )
814
805
@@ -821,7 +812,7 @@ class InlinerTest extends ClearAfterClass {
821
812
822
813
val m6 = getSingleMethod(c, " m6" )
823
814
assertInvoke(m6, " U" , " f" )
824
- assertInvoke(m6, " U$class " , " g" )
815
+ assertInvoke(m6, " U" , " g" )
825
816
assertInvoke(m6, " U" , " h" )
826
817
assertInvoke(m6, " U" , " i" )
827
818
}
0 commit comments