Skip to content

Commit 95d503a

Browse files
authored
Replace Kotlin setters with direct property access for models from Fuzzer #1241 (#1243)
Replace Kotlin setters with direct property access for models from Fuzzer
1 parent 1115aad commit 95d503a

File tree

2 files changed

+7
-8
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api

2 files changed

+7
-8
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,16 +1024,15 @@ sealed class ExecutableId : StatementId() {
10241024
return "$name($args)$retType"
10251025
}
10261026

1027+
fun describesSameMethodAs(other: ExecutableId): Boolean {
1028+
return classId == other.classId && signature == other.signature
1029+
}
1030+
10271031
override fun equals(other: Any?): Boolean {
10281032
if (this === other) return true
10291033
if (javaClass != other?.javaClass) return false
10301034

1031-
other as ExecutableId
1032-
1033-
if (classId != other.classId) return false
1034-
if (signature != other.signature) return false
1035-
1036-
return true
1035+
return describesSameMethodAs(other as ExecutableId)
10371036
}
10381037

10391038
override fun hashCode(): Int {

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/ClassIdUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ infix fun ClassId.isAccessibleFrom(packageName: String): Boolean {
4141
* Returns field of [this], such that [methodId] is a getter for it (or null if methodId doesn't represent a getter)
4242
*/
4343
internal fun ClassId.fieldThatIsGotWith(methodId: MethodId): FieldId? =
44-
allDeclaredFieldIds.singleOrNull { !it.isStatic && it.getter == methodId }
44+
allDeclaredFieldIds.singleOrNull { !it.isStatic && it.getter.describesSameMethodAs(methodId) }
4545

4646
/**
4747
* Returns field of [this], such that [methodId] is a setter for it (or null if methodId doesn't represent a setter)
4848
*/
4949
internal fun ClassId.fieldThatIsSetWith(methodId: MethodId): FieldId? =
50-
allDeclaredFieldIds.singleOrNull { !it.isStatic && it.setter == methodId }
50+
allDeclaredFieldIds.singleOrNull { !it.isStatic && it.setter.describesSameMethodAs(methodId) }

0 commit comments

Comments
 (0)