Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c022d38
Use local variables
mernst May 27, 2026
3d91ebd
Simplify logic
mernst May 27, 2026
30144ce
Warn about unneeded suppressions in tests
mernst May 27, 2026
5f7a230
Make type argument explicit
mernst May 27, 2026
d5d5c66
Merge ../checker-framework-branch-master into local-vars-2
mernst May 27, 2026
26cb9a8
Fix type mismatch
mernst May 27, 2026
1cd5d46
Add import
mernst May 27, 2026
73de83d
Improve efficiency of "unneeded.suppression" warning
mernst May 28, 2026
990b6a6
Tweak documentation
mernst May 28, 2026
7cedddc
Code review changes
mernst May 28, 2026
3c2c8b1
Warn about unneeded suppressions in tests
mernst May 28, 2026
6508322
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
ee084d7
Remove unnecessary `@SuppressWarnings`
mernst May 28, 2026
ad14893
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
c6bc342
Handle "allcheckers" as well as "all"
mernst May 28, 2026
d370f37
Reduce warning suppressions
mernst May 28, 2026
b35cf85
Merge ../checker-framework-fork-mernst-branch-local-vars-2 into warn-…
mernst May 28, 2026
5ace580
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
83391f6
Update jtreg tests
mernst May 28, 2026
b545b1d
Undo undesirable change
mernst May 28, 2026
27b40df
Adjust jtreg goal
mernst May 28, 2026
b7e2316
Grammar
mernst May 28, 2026
392d779
Merge ../checker-framework-branch-master into warn-unneeded-efficiency
mernst May 28, 2026
223dbd2
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
1bc7cb5
Add `@SuppressWarnings`
mernst May 28, 2026
661030d
Remove diagnostic output
mernst May 28, 2026
486879c
Merge branch 'master' into warn-unneeded-in-tests
mernst May 28, 2026
17a0681
Documentation
mernst May 28, 2026
b35090e
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
064e498
Merge ../checker-framework-branch-master into warn-unneeded-efficiency
mernst May 28, 2026
b066323
Merge ../checker-framework-fork-mernst-branch-warn-unneeded-efficienc…
mernst May 28, 2026
31a18bd
Merge ../checker-framework-branch-master into warn-unneeded-in-tests
mernst Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions checker/tests/calledmethods/EnsuresCalledMethodsIfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public static void closeSockOK2(EnsuresCalledMethodsIfTest sock) throws Exceptio

void close() throws IOException {}

@SuppressWarnings(
"calledmethods") // like the JDK's isOpen methods; makes this test case self-contained
@EnsuresCalledMethodsIf(
expression = "this",
result = false,
Expand Down
1 change: 0 additions & 1 deletion checker/tests/index/ArrayIntro.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.checkerframework.common.value.qual.MinLen;

@SuppressWarnings("lowerbound")
public class ArrayIntro {
void test() {
int @MinLen(5) [] arr = new int[5];
Expand Down
1 change: 0 additions & 1 deletion checker/tests/index/UpperBoundRefinement.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.checkerframework.checker.index.qual.LTLengthOf;

@SuppressWarnings("lowerbound")
public class UpperBoundRefinement {
// If expression i has type @LTLengthOf(value = "f2", offset = "f1.length") int and expression
// j is less than or equal to the length of f1, then the type of i + j is @LTLengthOf("f2")
Expand Down
2 changes: 0 additions & 2 deletions checker/tests/mustcall/PolyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ static void test2(@Owning @MustCall({}) Object o) {
@MustCall({}) Object o2 = id(o);
}

// These sort of constructors will always appear in stub files and are unverifiable for now.
@SuppressWarnings("mustcall:annotations.on.use")
@PolyMustCall PolyTests(@PolyMustCall Object obj) {}

static void test3(@Owning @MustCall({"close"}) Object o) {
Expand Down
4 changes: 1 addition & 3 deletions checker/tests/nullness-checkcastelementtype/Issue1315.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ T test1(@Nullable Object p) {
return (T) p;
}

// The Nullness Checker should not issue a cast.unsafe warning,
// but the KeyFor Checker does, so suppress that warning.
@SuppressWarnings({"unchecked", "keyfor:cast.unsafe"})
@SuppressWarnings("unchecked")
T test2(Object p) {
return (T) p;
}
Expand Down
2 changes: 0 additions & 2 deletions checker/tests/nullness/FullyQualifiedAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ void client2(Iterator i) {
}

void client3(Iterator<Object> i) {
@SuppressWarnings("nullness")
@org.checkerframework.checker.nullness.qual.NonNull Object handle2 = i.next();
handle2.toString();
}

void client4(Iterator<Object> i) {
@SuppressWarnings("nullness")
@org.checkerframework.checker.nullness.qual.NonNull Object handle2 = i.next();
handle2.toString();
}
Expand Down
1 change: 1 addition & 0 deletions checker/tests/nullness/SuppressWarningsPartialKeys.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.checkerframework.checker.nullness.qual.NonNull;

@SuppressWarnings("unneeded.suppression")
public class SuppressWarningsPartialKeys {

@SuppressWarnings("return")
Expand Down
2 changes: 0 additions & 2 deletions checker/tests/regex/GroupCounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ void testPatternCompileGroupCount(@Regex String r, @Regex(3) String r3, @Regex(5

// Make sure Pattern.compile still works when passed an @UnknownRegex String
// that's actually a regex, with the warning suppressed.
@SuppressWarnings("regex:argument")
Pattern p6 = Pattern.compile("(" + r + ")");
@SuppressWarnings("regex:argument")
Pattern p6a = Pattern.compile("(" + r + ")", 0);
}

Expand Down
3 changes: 0 additions & 3 deletions checker/tests/regex/MyMatchResult.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import java.util.regex.MatchResult;

// Outside of scope of the Regex Checker to verify an implementation of MatchResult,
// so just check for crashes.
@SuppressWarnings("regex")
public class MyMatchResult implements MatchResult {

@Override
Expand Down
4 changes: 0 additions & 4 deletions checker/tests/tainting/Issue2330.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
import org.checkerframework.checker.tainting.qual.Untainted;

public class Issue2330<T extends @Tainted Object> {
// Checker can't verify that this creates an untainted Issue2330
@SuppressWarnings("tainting")
public @Untainted Issue2330(@PolyTainted int i) {}

// Checker can't verify that this creates an untainted Issue2330
@SuppressWarnings("tainting")
public @Untainted Issue2330() {}

public static void f(@PolyTainted int i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ protected CheckerFrameworkPerDirectoryTest(
this.checkerOptions = new ArrayList<>(Arrays.asList(checkerOptions));
this.checkerOptions.add("-AajavaChecks");
this.checkerOptions.add("-AconvertTypeArgInferenceCrashToWarning=false");
this.checkerOptions.add("-AwarnUnneededSuppressions");
}

/** Run the tests. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ protected CheckerFrameworkPerFileTest(
this.testFile = testFile;
this.checker = checker;
this.testDir = testDir;
this.checkerOptions = new ArrayList<>(Arrays.asList(checkerOptions));
this.checkerOptions = new ArrayList<String>(Arrays.asList(checkerOptions));
this.checkerOptions.add("-AwarnUnneededSuppressions");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/** Encapsulates the directory root to search within for test files to compile. */
abstract class CheckerFrameworkRootedTest {

/** Constructs a test that will assert that can resolve its tests root directory. */
/** Constructs a test that uses {@code @TestRootDirectory} to find its test directory. */
public CheckerFrameworkRootedTest() {}

/**
Expand Down
7 changes: 4 additions & 3 deletions framework/tests/all-systems/ForEach.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ <T extends Object> void m4(T p) {
}
}

@SuppressWarnings(
"nonempty") // TODO: the Non-Empty Checker requires the Side Effects Only checker to
// eliminate the false positive here.
@SuppressWarnings({
"nonempty:argument",
"nonempty:method.invocation"
}) // generic type inference bug?
public static <T extends Object> List<T> removeDuplicates(List<T> l) {
// There are shorter solutions that do not maintain order.
HashSet<T> hs = new HashSet<>(l.size());
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/GenericNull.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class GenericNull {
* this test. For the Lock Checker, null's type is bottom for the @GuardedByUnknown hierarchy but
* not for the @LockPossiblyHeld hierarchy.
*/
@SuppressWarnings({"nullness", "lock"})
@SuppressWarnings("nullness")
<T> T f() {
return null;
}
Expand Down
7 changes: 0 additions & 7 deletions framework/tests/all-systems/GetClassTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ void context() {
Integer i = 4;
i.getClass();
Class<?> a = i.getClass();
// Type arguments don't match
@SuppressWarnings("fenum:assignment")
Class<? extends Object> b = i.getClass();
@SuppressWarnings({
"fenum:assignment", // Type arguments don't match
"signedness:assignment" // Type arguments don't match
})
Class<? extends Integer> c = i.getClass();

Class<?> d = i.getClass();
Expand All @@ -24,7 +18,6 @@ void context() {
}

void m(Date d) {
@SuppressWarnings("fenum:assignment")
Class<? extends Date> c = d.getClass();
}
}
1 change: 0 additions & 1 deletion framework/tests/all-systems/InferAndWildcards.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@SuppressWarnings("interning")
public class InferAndWildcards {
<UUU> Class<? extends UUU> b(Class<UUU> clazz) {
return clazz;
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/InferTypeArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected FlowAnalysis createFlowAnalysis() {
return result;
}

@SuppressWarnings({"nullness:return", "lock:return", "immutabilitysub:type.argument"})
@SuppressWarnings({"nullness:return", "immutabilitysub:type.argument"})
public static <T> T invokeConstructorFor() {
return null;
}
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/Issue1708.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
@SuppressWarnings({
"unchecked",
"ainfertest",
"value"
}) // Don't issue warnings during ainfer tests, because more than one round of inference is required
// for the value checker
public class Issue1708 {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/Issue1809.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface S {}

// The Checker Framework does not refine the type of Stream#filter based on post conditions of
// the passed function.
@SuppressWarnings({"nullness", "optional"})
// TODO: use more specific suppressions. @SuppressWarnings({"nullness", "optional"})
private Stream<A> xrefsFor(B b) {
return concat(b.g().stream().flatMap(a -> a.h().stream().map(c -> f())))
.filter(Optional::isPresent)
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/Issue457.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class Issue457<T extends Number> {
public void f(T t) {
final T obj = t;

@SuppressWarnings("signedness:assignment") // cast
Float objFloat = (obj instanceof Float) ? (Float) obj : null;

// An error will be emitted on this line before the fix for Issue457
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/Issue5042.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import java.util.function.Function;
import org.checkerframework.checker.nullness.qual.Nullable;

@SuppressWarnings("initializedfields") // The fields are initialized.
public class Issue5042 {
interface PromptViewModel {
boolean isPending();
Expand Down
5 changes: 2 additions & 3 deletions framework/tests/all-systems/Issue759.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
@SuppressWarnings({
"nullness",
"unchecked",
"ainfertest",
"value"
"ainfertest"
}) // See checker/test/nullness/Issue759.java; ainfertest and value are suppressed because WPI
// errors shouldn't be issued here, just checked for crashes
public class Issue759 {
Expand All @@ -28,7 +27,7 @@ T[] getConstants() {
}
}

@SuppressWarnings("nullness")
// @SuppressWarnings("nullness")
class IncompatibleTypes {
void possibleValues(final Gen<?> genType) {
lowercase(genType.getConstants());
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/MissingBoundAnnotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Map;

public final class MissingBoundAnnotations {
@SuppressWarnings("nullness:type.argument")
public static <K extends Comparable<? super K>, V> Collection<K> sortedKeySet(Map<K, V> m) {
ArrayList<K> theKeys = new ArrayList<>(m.keySet());
Collections.sort(theKeys);
Expand Down
5 changes: 1 addition & 4 deletions framework/tests/all-systems/SetOfSet.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package wildcards;

@SuppressWarnings({
"initialization",
"initializedfields:contracts.postcondition"
}) // field isn't set
@SuppressWarnings("initialization")
public class SetOfSet<E> {

public void addAll(SetOfSet<? extends E> s) {
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/WildcardCrash.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SomeGen(CFAbstractAnalysis123<CFValue123, ?, ?> analysis) {}

class CFValue123 extends CFAbstractValue123<CFValue123> {}

@SuppressWarnings({"initialization", "initializedfields:contracts.postcondition"})
@SuppressWarnings("initialization")
class CFAbstractTransfer123<
V extends CFAbstractValue123<V>,
S extends CFAbstractStore123<V, S>,
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/WildcardSuper2.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface AInterface<T> {

class B implements AInterface<Object> {
// This shouldn't work for nullness as the function won't take possibly nullable values.
@SuppressWarnings({"nullness", "fenum:override.param", "aliasing"})
// @SuppressWarnings({"nullness", "aliasing"})
@Override
public int transform(List<Object> function) {
return 0;
Expand Down
4 changes: 0 additions & 4 deletions framework/tests/all-systems/java17/Figure.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ public sealed class Figure
// defined in the same file.
{}

@SuppressWarnings("initializedfields:contracts.postcondition")
final class Circle extends Figure {
float radius;
}

@SuppressWarnings("initializedfields:contracts.postcondition")
non-sealed class Square extends Figure {
float side;
}

@SuppressWarnings("initializedfields:contracts.postcondition")
sealed class Rectangle extends Figure {
float length, width;
}

@SuppressWarnings("initializedfields:contracts.postcondition")
final class FilledRectangle extends Rectangle {
int red, green, blue, sealed;
}
1 change: 0 additions & 1 deletion framework/tests/all-systems/java17/Issue6100.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// @infer-jaifs-skip-test The AFU's JAIF reading/writing libraries don't support records.
// @below-java17-jdk-skip-test
@SuppressWarnings("signedness")
public record Issue6100(List<@NonNegative Integer> bar) {

public Issue6100 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void m(List<String> strings) {
// This works:
List<@Nullable String> collectedStrings2 = s.collect(Collectors.toList());
// This works:
@SuppressWarnings("nullness")
List<String> collectedStrings3 = s.collect(Collectors.toList());

// This assignment issues a warning due to incompatible types:
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/java8inference/Issue1397.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ abstract class CrashCompound {

abstract <T> T unbox(Box<T> p);

@SuppressWarnings("units")
void foo(Box<Boolean> bb) {
boolean res = false;
res |= chk(unbox(bb));
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/java8inference/Issue1407.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ abstract class Issue1407 {

abstract <T extends Number> T bar(int p1, T p2);

@SuppressWarnings({"interning", "signedness"})
int demo() {
return foo(bar(5, 3), 3);
}
Expand Down
1 change: 0 additions & 1 deletion framework/tests/all-systems/java8inference/Issue1416.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.stream.Stream;

public class Issue1416 {
@SuppressWarnings("signedness")
long order(Stream<Long> sl) {
return sl.max(Comparator.naturalOrder()).orElse(0L);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/tests/all-systems/java8inference/Issue6046.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface Record extends Comparable<Record>, Formattable {}

public interface Result<R extends Record> extends List<R>, Formattable {}

@SuppressWarnings({"unchecked", "nullness:new.array", "index:array.access.unsafe.high.constant"})
@SuppressWarnings({"unchecked", "index:array.access.unsafe.high.constant"})
public static <K, V extends Record, R extends Record>
Collector<R, ?, Map<K, Result<V>>> intoResultGroups(
Function<? super R, ? extends K> keyMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static <K1, V1> MemRefInfere<K1, V1> copyOf(Map<? extends K1, ? extends V
throw new RuntimeException();
}

@SuppressWarnings("lock:methodref.return")
public static <T, K2, V2> Collector<T, ?, MemRefInfere<K2, V2>> toImmutableMap(
Function<? super T, ? extends K2> keyFunction,
Function<? super T, ? extends V2> valueFunction,
Expand Down
3 changes: 0 additions & 3 deletions framework/tests/flow/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@ void foo1(@ValueTypeAnno(1) Object o) {}

void foo2(@ValueTypeAnno(2) Object o) {}

@SuppressWarnings("flowtest:return")
@ValueTypeAnno Object get() {
return null;
}

@SuppressWarnings("flowtest:return")
@ValueTypeAnno(1) Object get1() {
return null;
}

@SuppressWarnings("flowtest:return")
@ValueTypeAnno(2) Object get2() {
return null;
}
Expand Down
Loading