Skip to content

Replace Kotlin setters with direct property access for models from Fuzzer #1241 #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
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) }