Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace Kotlin setters with direct property access for models from Fu…
…zzer
  • Loading branch information
volivan239 committed Oct 26, 2022
commit 3cd2d5d6b1d900cdf6ffcd944fafe9ec66fcf073
Original file line number Diff line number Diff line change
Expand Up @@ -1053,16 +1053,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 @@ -37,10 +37,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) }