Skip to content

Incorrect equals() implementation in BaseItem #910

@Benjiko99

Description

@Benjiko99

About this issue

Incorrect equals() implementation in BaseItem.

Here's how the implementation looks like

override fun equals(other: Any?): Boolean {
    if (this === other) return true
    if (other == null || javaClass != other.javaClass) return false
    val that = other as? AbstractItem<*>?  
    return identifier == that?.identifier
}

The line val that = other as? AbstractItem<*>? should be replaced with val that = other as? BaseItem<*>?, as not all subclasses of BaseItem extend AbstractItem.

As an example AbstractBindingItem extends BaseItem directly, thus the equals() fails on it.

Details

  • [5.1.0] Used library version

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions