[infer][java] match the annotation by class name, forgetting the package, instead of checking if the end of the annotation matches

Summary:
Before the diff, the code was considering as Nullable any annotation ending with `...Nullable`, including `SuppressParameterNotNullable`.

Closes #533

Reviewed By: jberdine

Differential Revision: D4317356

fbshipit-source-id: 6091c0f
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 901786e0c5
commit 715f6ffa7e

@ -48,13 +48,11 @@ let ia_has_annotation_with
ia;
!found
(** Return true if [annot] ends with [ann_name] *)
(** Return true if [annot] ends with [ann_name], ignoring the package name *)
let annot_ends_with annot ann_name =
let filter s =
let sl = String.length s in
let al = String.length ann_name in
sl >= al && String.sub s ~pos:(sl - al) ~len:al = ann_name in
filter annot.Annot.class_name
match String.rsplit2 annot.Annot.class_name ~on:'.' with
| None -> String.equal annot.Annot.class_name ann_name
| Some (_, annot_class_name) -> String.equal annot_class_name ann_name
(** Check if there is an annotation in [ia] which ends with the given name *)
let ia_ends_with ia ann_name =

@ -0,0 +1,12 @@
/*
* Copyright (c) 2013 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package codetoanalyze.java.eradicate;
@interface DefinitelyNotNullable {}

@ -127,4 +127,13 @@ public class ReturnNotNullable {
return cls.getResource(name);
}
@DefinitelyNotNullable
Object definitelyDoesNotReturnNull() {
return new Object();
}
void callsnotnullableMethod() {
definitelyDoesNotReturnNull().toString();
}
}

Loading…
Cancel
Save