Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0abb3003 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tighter equals/hashCode method checking."

parents fa83dea8 40d623e6
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -403,9 +403,12 @@ def verify_extras(clazz):

def verify_equals(clazz):
    """Verify that equals() and hashCode() must be overridden together."""
    methods = [ m.name for m in clazz.methods ]
    eq = "equals" in methods
    hc = "hashCode" in methods
    eq = False
    hc = False
    for m in clazz.methods:
        if " static " in m.raw: continue
        if "boolean equals(java.lang.Object)" in m.raw: eq = True
        if "int hashCode()" in m.raw: hc = True
    if eq != hc:
        error(clazz, None, "M8", "Must override both equals and hashCode; missing one")