panacekcz / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
0 stars 0 forks source link

indexOf!=-1 means subsequent calls will succeed too #10

Open panacekcz opened 7 years ago

panacekcz commented 7 years ago

The code checks that s.indexOf(t)!=-1, then in the branch calls indexOf again with the same arguments. These calls cannot return -1 and should be usable as an index without further checking. Some cases can be solved by extracting the indexOf call to a local variable. However lastIndexOf should succeed as well. Colud be solved by adding an annotation @ContainsSubstring(t).