Summary: Get rid of false positive as in the test by modelling `Double`. Longer term we should probably prevent biabduction from blocking the angelic analysis on `Nullable` fields but that seems harder. Reviewed By: jeremydubreil Differential Revision: D14005228 fbshipit-source-id: 59ef2ed66master
parent
620099113d
commit
c79f966279
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2019-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package java.lang;
|
||||
|
||||
public final class Double {
|
||||
|
||||
protected final double value;
|
||||
|
||||
public Double(double i) {
|
||||
this.value = i;
|
||||
}
|
||||
|
||||
public static Double valueOf(double i) {
|
||||
return new Double(i);
|
||||
}
|
||||
|
||||
public boolean equals(Object anObject) {
|
||||
return anObject != null
|
||||
&& anObject instanceof Double
|
||||
&& this.value == ((Double) anObject).value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2019-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package codetoanalyze.java.infer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DoubleExample {
|
||||
|
||||
@Nullable Double x;
|
||||
|
||||
private Double testAssignNonNullOk() {
|
||||
x = 1.0;
|
||||
return x + 1.0;
|
||||
}
|
||||
|
||||
private Double testdReadNullableBad() {
|
||||
return x + 1.0;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue