[annotations] make override_exists recursive

Reviewed By: jeremydubreil

Differential Revision: D4496324

fbshipit-source-id: 4459cc1
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent c047819ab3
commit 6c0c3b44b4

@ -330,14 +330,15 @@ let proc_calls resolve_attributes pdesc filter : (Procname.t * ProcAttributes.t)
IList.rev !res
let override_exists f tenv proc_name =
let super_type_exists tenv super_class_name =
let rec super_type_exists tenv super_class_name =
let super_proc_name =
Procname.replace_class proc_name (Typename.name super_class_name) in
match Tenv.lookup tenv super_class_name with
| Some ({ methods }) ->
| Some ({ methods; supers; }) ->
let is_override pname =
Procname.equal pname super_proc_name && not (Procname.is_constructor pname) in
IList.exists (fun pname -> is_override pname && f pname) methods
IList.exists (fun pname -> is_override pname && f pname) methods ||
IList.exists (super_type_exists tenv) supers
| _ ->
false in
match proc_name with

@ -35,4 +35,18 @@ public interface ExpensiveInterfaceExample {
@Expensive
public void m5();
interface I2 extends I {
@PerformanceCritical void m3();
}
abstract class ImplementsInterface implements I2 {
@Expensive void expensive() {}
@Override public void m1() {
expensive();
}
}
}

@ -20,6 +20,7 @@ codetoanalyze/java/checkers/ExpensiveCallExample.java, void PerformanceCriticalS
codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, void ExpensiveInheritanceExample.doesReportBecauseTypeFlowInsensitive(A), 2, CHECKERS_CALLS_EXPENSIVE_METHOD, []
codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, void ExpensiveInheritanceExample.reportsAssumingObjectOfTypeA(), 2, CHECKERS_CALLS_EXPENSIVE_METHOD, []
codetoanalyze/java/checkers/ExpensiveInheritanceExample.java, void ExpensiveInheritanceExample.reportsBecauseFooIsExpensiveInA(A), 1, CHECKERS_CALLS_EXPENSIVE_METHOD, []
codetoanalyze/java/checkers/ExpensiveInterfaceExample.java, void ExpensiveInterfaceExample$ImplementsInterface.m1(), 1, CHECKERS_CALLS_EXPENSIVE_METHOD, []
codetoanalyze/java/checkers/ExpensiveSubtypingExample.java, void ExpensiveSubtypingExample.m3(), 0, CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED, [return from a call to void ExpensiveSubtypingExample.m4()]
codetoanalyze/java/checkers/FragmentRetainsViewExample.java, void FragmentRetainsViewExample.onDestroyView(), 0, CHECKERS_FRAGMENT_RETAINS_VIEW, [return from a call to void FragmentRetainsViewExample.onDestroyView()]
codetoanalyze/java/checkers/FragmentRetainsViewExample.java, void FragmentRetainsViewExample.onDestroyView(), 0, CHECKERS_FRAGMENT_RETAINS_VIEW, [return from a call to void FragmentRetainsViewExample.onDestroyView()]

Loading…
Cancel
Save