Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3617,14 +3617,11 @@ private[optimizer] abstract class OptimizerCore(
implicit val scope = scope1
val tRef = VarRef(tName)(rtLongClassType)

val lo = Apply(ApplyFlags.empty, tRef, MethodIdent(LongImpl.lo), Nil)(IntType)
val hi = Apply(ApplyFlags.empty, tRef, MethodIdent(LongImpl.hi), Nil)(IntType)

pretransformExprs(lo, hi) { (tlo, thi) =>
inlineClassConstructor(AllocationSite.Anonymous, LongImpl.RuntimeLongClass,
inlinedRTLongStructure, MethodIdent(LongImpl.initFromParts), List(tlo, thi),
() => throw new AssertionError(s"rolled-back RuntimeLong inlining at $pos"))(cont1)
}
val newTree = New(LongImpl.RuntimeLongClass,
MethodIdent(LongImpl.initFromParts),
List(Apply(ApplyFlags.empty, tRef, MethodIdent(LongImpl.lo), Nil)(IntType),
Apply(ApplyFlags.empty, tRef, MethodIdent(LongImpl.hi), Nil)(IntType)))
pretransformExpr(newTree)(cont1)
} (cont)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,28 @@ class OptimizerTest {

assertTrue(called)
}

@Test def expandedRTAssertionOriginal_Issue5231(): Unit = {
def expandedRTLongBug: (Array[Int], Long) => Long = { (array, z) =>
array.foldRight(z)(_ - _)
}

assertEquals(-3L, expandedRTLongBug(Array(1, 2, 3), 5L))
}

@Test def expandedRTAssertionMinimal_Issue5231(): Unit = {
@noinline def hideLong(x: Long): Long = x
@noinline def hide(x: Any): Any = x

val z0: Long = hideLong(5L)
var i = 0
var z: Any = z0
while (i < 2) {
z = hide(i.toLong)
i += 1
}
assertEquals(1L, z)
}
}

object OptimizerTest {
Expand Down
Loading