Skip to content

Commit a8111ef

Browse files
author
Sascha Kehrli
committed
address trivial coderabbit PR comments
1 parent b105a8a commit a8111ef

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

checker/src/main/java/org/checkerframework/checker/collectionownership/CollectionOwnershipChecker.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.checkerframework.checker.collectionownership;
22

3+
import java.util.LinkedHashSet;
34
import java.util.Set;
45
import org.checkerframework.checker.rlccalledmethods.RLCCalledMethodsChecker;
56
import org.checkerframework.common.basetype.BaseTypeChecker;
@@ -17,7 +18,8 @@ public CollectionOwnershipChecker() {}
1718

1819
@Override
1920
protected Set<Class<? extends SourceChecker>> getImmediateSubcheckerClasses() {
20-
Set<Class<? extends SourceChecker>> checkers = super.getImmediateSubcheckerClasses();
21+
Set<Class<? extends SourceChecker>> checkers =
22+
new LinkedHashSet<>(super.getImmediateSubcheckerClasses());
2123
checkers.add(RLCCalledMethodsChecker.class);
2224
return checkers;
2325
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
owning.override.return=Incompatible ownership for return.%nfound : no ownership annotation or @Owning%nrequired: @NotOwning%nConsequence: method %s in %s cannot override method %s in %s
2-
owning.override.param=Incompatible ownership for parameter %s.%nfound : no ownership annotation or @NotOwning%nrequired: @Owning%nConsequence: method %s in %s cannot override method %s in %s
1+
owning.override.return=Incompatible ownership of return type.%nfound : no ownership annotation or @Owning%nrequired: @NotOwning%nConsequence: method %s in %s cannot override method %s in %s
2+
owning.override.param=Incompatible ownership of parameter %s.%nfound : no ownership annotation or @NotOwning%nrequired: @Owning%nConsequence: method %s in %s cannot override method %s in %s

checker/src/test/java/org/checkerframework/checker/test/junit/ResourceLeakCollections.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest;
77
import org.junit.runners.Parameterized.Parameters;
88

9-
/** Tests for the Resource Leak Checker. */
9+
/** Tests for the Resource Leak Checker for Collections. */
1010
public class ResourceLeakCollections extends CheckerFrameworkPerDirectoryTest {
1111
public ResourceLeakCollections(List<File> testFiles) {
1212
super(

checker/tests/resourceleak/EnhancedFor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ void test2(List<@MustCall Socket> list) {
2626
}
2727

2828
void test3(List<Socket> list) {
29-
// With the extension of the RLC to collections, this is no longer an error.
30-
// The return type of Iterator#next is NotOwning, because the iterator does not
31-
// own the elements, but instead the host collection the iterator is associated with.
29+
// With the RLC collection extension, this is no longer an error.
30+
// Iterator#next returns @NotOwning: iterators do not own their elements; ownership
31+
// stays with the host collection associated with the iterator.
3232
for (Socket s : list) {}
3333
}
3434

checker/tests/resourceleak/Issue4815.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public <T extends Component> void initialize(
1010
object.initialize();
1111
// `list` resolves to List<@MustCall Component> and thus cannot accept
1212
// an element of non-empty @MustCall type enforced by the Java
13-
// typechecker. This is an unfortunate consequence of the otherwise
13+
// type checker. This is an unfortunate consequence of the otherwise
1414
// elegant extension of the RLC to collections, which doesn't detect
1515
// that object already fulfilled its obligation here.
1616
// :: error: argument

checker/tests/resourceleak/SocketIntoList.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ public List<Socket> test2(@OwningCollection List<Socket> l) {
2323
}
2424

2525
public void test3(List<@MustCall({}) Socket> l) throws Exception {
26-
// although s is illegally assigned into the list l, an error
27-
// for required.method.not.called is not additionally reported at
28-
// this declaration site of s. list#add(@Owning E) takes on
29-
// the obligation of the argument.
26+
// although s is illegally added to l, a required.method.not.called error
27+
// is not additionally reported at this declaration site. List#add(@Owning E) takes on
28+
// the obligation of its argument.
3029
Socket s = new Socket();
3130
s.bind(new InetSocketAddress("192.168.0.1", 0));
3231
// l cannot hold elements with non-empty @MustCall values

dataflow/src/main/java/org/checkerframework/dataflow/cfg/visualize/CFGVisualizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public interface CFGVisualizer<
108108
* element.
109109
*
110110
* @param ice the iterated collection element
111-
* @param value the value of the local variable
112-
* @return the String representation of the local variable
111+
* @param value the value associated with {@code ice}
112+
* @return the String representation of this entry
113113
*/
114114
String visualizeStoreIteratedCollectionElt(IteratedCollectionElement ice, V value);
115115

dataflow/src/main/java/org/checkerframework/dataflow/expression/IteratedCollectionElement.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public class IteratedCollectionElement extends JavaExpression {
2020
/**
2121
* Creates a new IteratedCollectionElement.
2222
*
23-
* @param var a CFG node
23+
* @param node CFG node
2424
* @param tree an AST tree
2525
*/
26-
public IteratedCollectionElement(Node var, Tree tree) {
27-
super(var.getType());
28-
this.node = var;
26+
public IteratedCollectionElement(Node node, Tree tree) {
27+
super(node.getType());
28+
this.node = node;
2929
this.tree = tree;
3030
}
3131

framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,8 +3020,8 @@ protected void checkExceptionParameter(CatchTree tree) {
30203020

30213021
/**
30223022
* Returns a set of AnnotationMirrors that is a lower bound for exception parameters. If a user
3023-
* writes a more specific (lower) annotation that this on an exception parameter, the Checker
3024-
* Framework issues a warning saying that the written annotation cannot be verified.
3023+
* writes a more specific (lower) annotation than this on an exception parameter, the Checker
3024+
* Framework issues a warning indicating that the written annotation cannot be verified.
30253025
*
30263026
* <p>This implementation returns top; subclasses can change this behavior.
30273027
*
@@ -3086,7 +3086,7 @@ protected void checkThrownExpression(ThrowTree tree) {
30863086
* Returns a set of AnnotationMirrors that is an upper bound for thrown exceptions.
30873087
*
30883088
* <p>Note: by default this method returns {@code getExceptionParameterLowerBoundAnnotations()},
3089-
* so that this annotation is enforced.
3089+
* so that the same bound is enforced.
30903090
*
30913091
* <p>(Default is top.)
30923092
*

framework/src/main/java/org/checkerframework/framework/flow/CFAbstractStore.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,9 @@ private S upperBound(S other, boolean shouldWiden) {
12381238
if (thisVal != null) {
12391239
V otherVal = e.getValue();
12401240
V mergedVal = upperBoundOfValues(otherVal, thisVal, shouldWiden);
1241-
newStore.iteratedCollectionElements.put(ice, mergedVal);
1241+
if (mergedVal != null) {
1242+
newStore.iteratedCollectionElements.put(ice, mergedVal);
1243+
}
12421244
}
12431245
}
12441246

0 commit comments

Comments
 (0)