EA-114349 Fix bug when trace collecting for large int values throws NPE

This commit is contained in:
Vitaliy.Bibaev
2017-12-27 17:01:27 +03:00
committed by Yan Zhulanow
parent 7cd1baff9d
commit fbc2a5d9a7
3 changed files with 12 additions and 3 deletions
@@ -28,9 +28,9 @@ class KotlinDistinctByHandler(callNumber: Int, private val call: IntermediateStr
private val keyExtractor: CallArgument
private val extractorVariable: Variable
private val beforeTimes = dsl.list(dsl.types.INT, call.name + callNumber + "BeforeTimes")
private val beforeValues = dsl.list(KotlinTypes.NULLABLE_ANY, call.name + callNumber + "BeforeValues")
private val beforeValues = dsl.list(call.typeBefore, call.name + callNumber + "BeforeValues")
private val keys = dsl.list(KotlinTypes.NULLABLE_ANY, call.name + callNumber + "Keys")
private val time2ValueAfter = dsl.linkedMap(dsl.types.INT, KotlinTypes.NULLABLE_ANY, call.name + callNumber + "after")
private val time2ValueAfter = dsl.linkedMap(dsl.types.INT, call.typeAfter, call.name + callNumber + "after")
init {
val arguments = call.arguments
@@ -81,7 +81,7 @@ class KotlinDistinctByHandler(callNumber: Int, private val call: IntermediateStr
forEachLoop(variable(types.INT, "afterTime"), time2ValueAfter.keys()) {
val afterTime = loopVariable
val valueAfter = declare(variable(KotlinTypes.NULLABLE_ANY, "valueAfter"), time2ValueAfter.get(loopVariable), false)
val valueAfter = declare(variable(call.typeAfter, "valueAfter"), time2ValueAfter.get(loopVariable), false)
val key = declare(variable(KotlinTypes.NULLABLE_ANY, "key"), nullExpression, true)
integerIteration(beforeTimes.size(), forEachLoop@ this) {
ifBranch((valueAfter same beforeValues.get(loopVariable)) and !transitions.contains(beforeTimes.get(loopVariable))) {
@@ -0,0 +1,8 @@
package distinct
fun main(args: Array<String>) {
// Breakpoint!
val seq = (22..25).map { it * it }.asSequence()
.distinctBy { it.toString().first() }
.count()
}
@@ -12,4 +12,5 @@ class DistinctOperationsTest : OperationsTestCase("distinct") {
fun testDistinctByNullableElement() = doTestWithResult()
fun testDistinctByNullableKey() = doTestWithResult()
fun testDistinctByNullableKeyAndElement() = doTestWithResult()
fun testDistinctByBigPrimitives() = doTestWithResult()
}