diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java index 62577e94cc..fca196b464 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListing.java @@ -163,7 +163,12 @@ private static boolean canSort(Tree array, VisitorState state) { /* For now we don't force sorting on numeric types. */ return Stream.of( - symtab.annotationType, symtab.classType, symtab.enumSym.type, symtab.stringType) + symtab.annotationType, + symtab.booleanType, + symtab.charType, + symtab.classType, + symtab.enumSym.type, + symtab.stringType) .anyMatch(t -> ASTHelpers.isSubtype(elemType, t, state)); } diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java index da842fd92a..b73458a5e3 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/LexicographicalAnnotationAttributeListingTest.java @@ -29,6 +29,10 @@ void identification() { " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " int[] ints() default {};", "", " Class[] cls() default {};", @@ -69,6 +73,32 @@ void identification() { " @Foo({\"a\", \"A\"})", " A unsortedStringCaseInsensitiveWithTotalOrderFallback();", "", + " @Foo(bools = {})", + " A noBools();", + "", + " @Foo(bools = {false})", + " A oneBool();", + "", + " @Foo(bools = {false, true})", + " A sortedBools();", + "", + " // BUG: Diagnostic contains:", + " @Foo(bools = {true, false})", + " A unsortedBools();", + "", + " @Foo(chars = {})", + " A noChars();", + "", + " @Foo(chars = {'a'})", + " A oneChar();", + "", + " @Foo(chars = {'a', 'b'})", + " A sortedChars();", + "", + " // BUG: Diagnostic contains:", + " @Foo(chars = {'b', 'a'})", + " A unsortedChars();", + "", " @Foo(ints = {})", " A noInts();", "", @@ -173,6 +203,10 @@ LexicographicalAnnotationAttributeListing.class, getClass()) " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " Class[] cls() default {};", "", " RoundingMode[] enums() default {};", @@ -185,7 +219,13 @@ LexicographicalAnnotationAttributeListing.class, getClass()) " }", "", " @Foo({\" \", \"\", \"b\", \"a\"})", - " A unsortedString();", + " A unsortedStrings();", + "", + " @Foo(bools = {true, false})", + " A unsortedBooleans();", + "", + " @Foo(chars = {'b', 'a'})", + " A unsortedChars();", "", " @Foo(cls = {long.class, int.class})", " A unsortedClasses();", @@ -210,6 +250,10 @@ LexicographicalAnnotationAttributeListing.class, getClass()) " @interface Foo {", " String[] value() default {};", "", + " boolean[] bools() default {};", + "", + " char[] chars() default {};", + "", " Class[] cls() default {};", "", " RoundingMode[] enums() default {};", @@ -222,7 +266,13 @@ LexicographicalAnnotationAttributeListing.class, getClass()) " }", "", " @Foo({\"\", \" \", \"a\", \"b\"})", - " A unsortedString();", + " A unsortedStrings();", + "", + " @Foo(bools = {false, true})", + " A unsortedBooleans();", + "", + " @Foo(chars = {'a', 'b'})", + " A unsortedChars();", "", " @Foo(cls = {int.class, long.class})", " A unsortedClasses();", diff --git a/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java b/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java index ac713c5589..06bfd5c5f4 100644 --- a/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java +++ b/error-prone-utils/src/test/java/tech/picnic/errorprone/utils/ThirdPartyLibraryTest.java @@ -73,7 +73,7 @@ void isIntroductionAllowedWitnessClassesNotOnClassPath() { } @ParameterizedTest - @ValueSource(booleans = {true, false}) + @ValueSource(booleans = {false, true}) void isIntroductionAllowedIgnoreClasspathCompat(boolean ignoreClassPath) { CompilationTestHelper.newInstance(IsIntroductionAllowedTestChecker.class, getClass()) .setArgs("-XepOpt:ErrorProneSupport:IgnoreClasspathCompat=" + ignoreClassPath)