Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Martin Kellogg <kelloggm@cs.washington.edu>
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
checker/tests/calledmethods/EnsuresCalledMethodsThisLub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import org.checkerframework.checker.calledmethods.qual.CalledMethods; | ||
import org.checkerframework.checker.calledmethods.qual.EnsuresCalledMethods; | ||
|
||
class EnsuresCalledMethodsThisLub { | ||
|
||
@EnsuresCalledMethods( | ||
value = "#1", | ||
methods = {"toString", "equals"}) | ||
void call1(Object obj) { | ||
obj.toString(); | ||
obj.equals(null); | ||
} | ||
|
||
@EnsuresCalledMethods( | ||
value = "#1", | ||
methods = {"toString", "hashCode"}) | ||
void call2(Object obj) { | ||
obj.toString(); | ||
obj.hashCode(); | ||
} | ||
|
||
void test(boolean b) { | ||
if (b) { | ||
call1(this); | ||
} else { | ||
call2(this); | ||
} | ||
@CalledMethods("toString") Object obj1 = this; | ||
// :: error: (assignment) | ||
@CalledMethods({"toString", "equals"}) Object obj2 = this; | ||
} | ||
|
||
void test_arg(Object arg, boolean b) { | ||
if (b) { | ||
call1(arg); | ||
} else { | ||
call2(arg); | ||
} | ||
@CalledMethods("toString") Object obj1 = arg; | ||
// :: error: (assignment) | ||
@CalledMethods({"toString", "equals"}) Object obj2 = arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters