Skip to content

Commit

Permalink
Replace Kotlin setters with direct property access for models from Fu…
Browse files Browse the repository at this point in the history
…zzer #1241 (#1243)

Replace Kotlin setters with direct property access for models from Fuzzer
  • Loading branch information
volivan239 authored Nov 1, 2022
1 parent 1115aad commit 95d503a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
allDeclaredFieldIds.singleOrNull { !it.isStatic && it.setter.describesSameMethodAs(methodId) }

0 comments on commit 95d503a

Please sign in to comment.