diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt index 2cf038e397..bdeffaae3e 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt @@ -1024,16 +1024,15 @@ sealed class ExecutableId : StatementId() { return "$name($args)$retType" } + fun describesSameMethodAs(other: ExecutableId): Boolean { + return classId == other.classId && signature == other.signature + } + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false - other as ExecutableId - - if (classId != other.classId) return false - if (signature != other.signature) return false - - return true + return describesSameMethodAs(other as ExecutableId) } override fun hashCode(): Int { diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/ClassIdUtil.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/ClassIdUtil.kt index 783037eb7e..aa9c00190c 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/ClassIdUtil.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/ClassIdUtil.kt @@ -41,10 +41,10 @@ infix fun ClassId.isAccessibleFrom(packageName: String): Boolean { * Returns field of [this], such that [methodId] is a getter for it (or null if methodId doesn't represent a getter) */ internal fun ClassId.fieldThatIsGotWith(methodId: MethodId): FieldId? = - allDeclaredFieldIds.singleOrNull { !it.isStatic && it.getter == methodId } + allDeclaredFieldIds.singleOrNull { !it.isStatic && it.getter.describesSameMethodAs(methodId) } /** * Returns field of [this], such that [methodId] is a setter for it (or null if methodId doesn't represent a setter) */ internal fun ClassId.fieldThatIsSetWith(methodId: MethodId): FieldId? = - allDeclaredFieldIds.singleOrNull { !it.isStatic && it.setter == methodId } \ No newline at end of file + allDeclaredFieldIds.singleOrNull { !it.isStatic && it.setter.describesSameMethodAs(methodId) } \ No newline at end of file