@@ -668,14 +668,19 @@ class OptimizationBytecodeTests extends DottyBytecodeTest {
668668 )
669669
670670 @ Test def cleanArrayMapInPlaceVal =
671- assertNoCalls(
672- " (a: Array[Int]) = a.mapInPlace(_ + 1)"
671+ testEquivalence(
672+ " var i = 0; while i < a.length do { val temp = a(i) + 1; a(i) = temp; i += 1 }; a" ,
673+ " a.mapInPlace(_ + 1)" ,
674+ params = List (" a: Array[Int]" ),
675+ returnType = " Array[Int]"
673676 )
674677
675678 @ Test def cleanArrayMapInPlaceRef =
676- assertNoCallsExcept(
677- " (a: Array[String]) = a.mapInPlace(_.trim)" ,
678- Set (" trim" )
679+ testEquivalence(
680+ " var i = 0; while i < a.length do { var temp = a(i).trim; a(i) = temp; temp = null; i += 1 }; a" ,
681+ " a.mapInPlace(_.trim)" ,
682+ params = List (" a: Array[String]" ),
683+ returnType = " Array[String]"
679684 )
680685
681686 @ Test def cleanArrayCountVal =
@@ -696,25 +701,28 @@ class OptimizationBytecodeTests extends DottyBytecodeTest {
696701
697702
698703 @ Test def inlineSingleAbstractMethod =
699- assertNoCalls(
700- " (i: Impl) = i.foo()" ,
704+ testEquivalence(
705+ " if i eq null then throw null; 42" ,
706+ " i.foo()" ,
707+ params = List (" i: Impl" ),
701708 extraMemberSources = List (
702709 " abstract class SAM { def foo(): Int }" ,
703710 " final class Impl extends SAM { def foo() = 42 }"
704711 )
705712 )
706713
707714 @ Test def inlineSingleAbstractMethodLambda =
708- assertNoCalls(
709- " () = call(n => n + 1)" ,
715+ testEquivalence(
716+ " { val a = 9; a + 1 } + { val b = 31; b + 1 }" ,
717+ " call(n => n + 1)" ,
710718 extraMemberSources = List (
711719 " trait MyIntFunction { def foo(n: Int): Int }" ,
712720 " def call(f: MyIntFunction): Int = f.foo(9) + f.foo(31)"
713721 )
714722 )
715723
716724
717- // Regression tes for bugs found during optimizer development
725+ // Regression tests for bugs found during optimizer development
718726
719727 @ Test def inlinedForeachBodyNotLost = {
720728 val source =
0 commit comments