Skip to content

Commit 2bcd1cf

Browse files
committed
Fixed CF bugs
1 parent 1d4d21a commit 2bcd1cf

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/io/usethesource/vallang/IWithKeywordParameters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface IWithKeywordParameters<T extends IValue> {
2626
* @param label identifies the parameter
2727
* @return a value if the parameter has a value on this node or null otherwise
2828
*/
29-
public <X extends IValue> @Nullable X getParameter(String label);
29+
public <X extends @Nullable IValue> X getParameter(String label);
3030

3131
/**
3232
* Set the value of an parameter

src/main/java/io/usethesource/vallang/impl/fields/AbstractDefaultWithKeywordParameters.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
import java.util.Collections;
1515
import java.util.Map;
1616
import java.util.Set;
17-
17+
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
1818
import org.checkerframework.checker.nullness.qual.Nullable;
1919
import org.checkerframework.dataflow.qual.Pure;
20-
2120
import io.usethesource.capsule.util.collection.AbstractSpecialisedImmutableMap;
2221
import io.usethesource.vallang.IValue;
2322
import io.usethesource.vallang.IWithKeywordParameters;
@@ -67,7 +66,7 @@ public String toString() {
6766

6867
@SuppressWarnings("unchecked")
6968
@Override
70-
public @Nullable <X extends IValue> X getParameter(String label) {
69+
public <X extends @Nullable IValue> X getParameter(String label) {
7170
return (X) parameters.get(label);
7271
}
7372

@@ -92,7 +91,8 @@ public T unsetAll() {
9291
}
9392

9493
@Override
95-
@Pure
94+
@SuppressWarnings("contracts.conditional.postcondition") // CF has a bug around super classes with EnsuresNonNullIf
95+
@EnsuresNonNullIf(expression="getParameter(#1)", result=true)
9696
public boolean hasParameter(String label) {
9797
return parameters.containsKey(label);
9898
}

src/main/java/io/usethesource/vallang/type/FunctionType.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
import java.util.function.BiFunction;
2323
import java.util.function.Function;
2424
import java.util.stream.Collectors;
25-
25+
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
2626
import org.checkerframework.checker.nullness.qual.Nullable;
27-
2827
import io.usethesource.vallang.IConstructor;
2928
import io.usethesource.vallang.IList;
3029
import io.usethesource.vallang.IListWriter;
@@ -212,6 +211,8 @@ public Type getKeywordParameterTypes() {
212211
}
213212

214213
@Override
214+
@SuppressWarnings("contracts.conditional.postcondition") // CF has a bug around superclass annotations
215+
@EnsuresNonNullIf(expression="getKeywordParameterType(#1)", result=true)
215216
public boolean hasKeywordParameter(String label) {
216217
return keywordParameters != null ? keywordParameters.hasField(label) : false;
217218
}

src/main/java/io/usethesource/vallang/type/TypeStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ public boolean hasKeywordParameters(Type onType) {
910910
}
911911
}
912912

913+
@SuppressWarnings({"flowexpr.parameter.not.final", "contracts.conditional.postcondition"}) // CF has issues trusting our annotation
913914
@EnsuresNonNullIf(expression="getKeywordParameterType(#1,#2)", result=true)
914915
public boolean hasKeywordParameter(Type onType, String label) {
915916
if (!onType.isConstructor()) {

0 commit comments

Comments
 (0)