Skip to content

Commit 4eca012

Browse files
committed
Fixed UtLambdaModel caching
1 parent b05ce23 commit 4eca012

File tree

2 files changed

+19
-1
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/engine
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api

2 files changed

+19
-1
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,21 @@ class UtLambdaModel(
566566
?: error("More than one method with name $lambdaName found in class: ${declaringClass.canonicalName}")
567567

568568
override fun toString(): String = "Anonymous function $lambdaName implementing functional interface $declaringClass"
569+
570+
override fun equals(other: Any?): Boolean {
571+
if (this === other) return true
572+
if (javaClass != other?.javaClass) return false
573+
574+
other as UtLambdaModel
575+
576+
if (id != other.id) return false
577+
578+
return true
579+
}
580+
581+
override fun hashCode(): Int {
582+
return id ?: 0
583+
}
569584
}
570585

571586
/**

utbot-framework/src/main/kotlin/org/utbot/engine/Resolver.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,15 @@ class Resolver(
662662
builder.toString()
663663
}
664664

665-
return UtLambdaModel(
665+
val lambdaModel = UtLambdaModel(
666666
id = addr,
667667
samType = samType,
668668
declaringClass = declaringClass.id,
669669
lambdaName = lambdaName
670670
)
671+
addConstructedModel(addr, lambdaModel)
672+
673+
return lambdaModel
671674
}
672675

673676
private fun constructEnum(addr: Address, type: RefType, clazz: Class<*>): UtEnumConstantModel {

0 commit comments

Comments
 (0)