Skip to content

Commit 226782f

Browse files
committed
Fixed UtLambdaModel caching
1 parent ee4bcd3 commit 226782f

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
@@ -569,6 +569,21 @@ class UtLambdaModel(
569569
?: error("More than one method with name $lambdaName found in class: ${declaringClass.canonicalName}")
570570

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

574589
/**

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)