Always consider Java types as subtypes of themselves

Summary: public
I realized that this code was returning false for `android.content.Context <: android.content.Context`.

Reviewed By: cristianoc

Differential Revision: D2699112

fb-gh-sync-id: 4c01c42
master
jrm 9 years ago committed by facebook-github-bot-5
parent d712635feb
commit b598c747b5

@ -278,7 +278,7 @@ let get_all_supertypes typ tenv =
and get_supers_rec typ tenv all_supers = and get_supers_rec typ tenv all_supers =
let direct_supers = get_direct_supers typ in let direct_supers = get_direct_supers typ in
IList.fold_left (fun typs (_, name) -> add_typ name typs) all_supers direct_supers in IList.fold_left (fun typs (_, name) -> add_typ name typs) all_supers direct_supers in
get_supers_rec typ tenv TypSet.empty get_supers_rec typ tenv (TypSet.add typ TypSet.empty)
(** return true if [typ0] <: [typ1] *) (** return true if [typ0] <: [typ1] *)
let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) tenv = let is_subtype (typ0 : Sil.typ) (typ1 : Sil.typ) tenv =

@ -9,6 +9,11 @@
"file": "codetoanalyze/java/infer/ContextLeaks.java", "file": "codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "void ContextLeaks.directLeak()" "procedure": "void ContextLeaks.directLeak()"
}, },
{
"bug_type": "CONTEXT_LEAK",
"file": "codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context)"
},
{ {
"bug_type": "CONTEXT_LEAK", "bug_type": "CONTEXT_LEAK",
"file": "codetoanalyze/java/infer/ContextLeaks.java", "file": "codetoanalyze/java/infer/ContextLeaks.java",

@ -9,6 +9,11 @@
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java", "file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "void ContextLeaks.directLeak()" "procedure": "void ContextLeaks.directLeak()"
}, },
{
"bug_type": "CONTEXT_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",
"procedure": "ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context)"
},
{ {
"bug_type": "CONTEXT_LEAK", "bug_type": "CONTEXT_LEAK",
"file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java", "file": "infer/tests/codetoanalyze/java/infer/ContextLeaks.java",

@ -45,7 +45,8 @@ public class ContextLeaksTest {
"nonStaticInnerClassLeak", "nonStaticInnerClassLeak",
"leakAfterInstanceFieldWrite", "leakAfterInstanceFieldWrite",
"singletonLeak", "singletonLeak",
"indirectHandlerLeak" "indirectHandlerLeak",
"getInstance",
}; };
assertThat( assertThat(
"Results should contain " + CONTEXT_LEAK, "Results should contain " + CONTEXT_LEAK,

Loading…
Cancel
Save