@ Nullable private Symbol . MethodSymbol getClosestOverriddenMethod ( Symbol . MethodSymbol method , Types types ) { // taken from Error Prone MethodOverrides check Symbol . ClassSymbol owner = method . enclClass ( ) ; for ( Type s : types . closure ( owner . type ) ) { if ( types . isSameType ( s , owner . type ) ) { continue ; } for ( Symbol m : s . tsym . members ( ) . getSymbolsByName ( method . name ) ) { if ( ! ( m instanceof Symbol . MethodSymbol ) ) { continue ; } Symbol . MethodSymbol msym = ( Symbol . MethodSymbol ) m ; if ( msym . isStatic ( ) ) { continue ; } if ( method . overrides ( msym , owner , types , /*checkReturn*/ false ) ) { return msym ; } } } return null ; }
find the closest ancestor method in a superclass or superinterface that method overrides