Debian Codegraph @

framework/tests/whole-program-inference/non-annotated/DefaultsTest.java

raw
1 import testlib.wholeprograminference.qual.*;
2
3 // The @DefaultType annotation, which is the default for every location, is forbidden
4 // to be written anywhere. This class attempts to infer @DefaultType in several
5 // locations, and the annotated version of this class (in the annotated folder)
6 // should have no explicit @DefaultType annotations.
7 public class DefaultsTest {
8 String defaultField = "";
9 String defaultField2;
10
11 void test() {
12 @SuppressWarnings("") // To allow the use of the explicit @DefaultType.
13 @DefaultType String explicitDefault = "";
14 defaultField2 = explicitDefault;
15 }
16
17 // This method's return type should not be updated by the whole-program inference
18 // since it is the default.
19 String lubTest() {
20 if (Math.random() > 0.5) {
21 return ""; // @DefaultType
22 } else {
23 // :: warning: (cast.unsafe)
24 @WholeProgramInferenceBottom String s = (@WholeProgramInferenceBottom String) "";
25 return s;
26 }
27 }
28 }