Skip to content

Commit

Permalink
Test overload support
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Jan 28, 2024
1 parent 4fb2962 commit b969b95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static com.google.errorprone.matchers.Matchers.annotations;
import static com.google.errorprone.matchers.Matchers.isType;
import static java.util.Comparator.comparing;
import static java.util.Comparator.naturalOrder;
import static java.util.stream.Collectors.toCollection;
import static tech.picnic.errorprone.bugpatterns.util.Documentation.BUG_PATTERNS_BASE_URL;

Expand Down Expand Up @@ -194,7 +193,10 @@ private static Comparator<String> signatureOrder(ImmutableList<String> existingO
knownEntries.putIfAbsent(existingOrder.get(i), i);
}

return comparing((String v) -> knownEntries.getOrDefault(v, -1)).thenComparing(naturalOrder());
// XXX: The lexicographical order applied to unknown entries aims to match the order applied by
// the `LexicographicalAnnotationAttributeListing` check; consider deduplicating this logic.
return comparing((String v) -> knownEntries.getOrDefault(v, -1))
.thenComparing(String.CASE_INSENSITIVE_ORDER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ void replacement() {
" public String publicStringMethodWithArg(int arg) {",
" return String.valueOf(arg);",
" }",
"",
" public String publicStringMethodWithArg(String arg) {",
" return arg;",
" }",
"}")
.expectUnchanged()
.addInputLines(
Expand All @@ -191,6 +195,7 @@ void replacement() {
" class AnnotatedWithIncorrectMethodReference {",
" @BeforeTemplate",
" void before() {",
" new Util().publicStringMethodWithArg(\"1\");",
" Util.publicStaticVoidMethod();",
" Util.publicStaticIntMethod2();",
" }",
Expand All @@ -203,6 +208,7 @@ void replacement() {
" @BeforeTemplate",
" void before() {",
" new Util().publicStringMethodWithArg(1);",
" new Util().publicStringMethodWithArg(\"1\");",
" Util.publicStaticIntMethod2();",
" }",
" }",
Expand All @@ -214,7 +220,12 @@ void replacement() {
"",
"class A {",
" @TypeMigration(",
" unmigratedMethods = {\"Util()\", \"publicStaticVoidMethod()\", \"publicStringMethodWithArg(int)\"},",
" unmigratedMethods = {",
" \"publicStaticVoidMethod()\",",
" \"publicStringMethodWithArg(int)\",",
" \"publicStringMethodWithArg(String)\",",
" \"Util()\"",
" },",
" of = Util.class)",
" class AnnotatedWithoutMethodListing {",
" {",
Expand All @@ -227,12 +238,11 @@ void replacement() {
" }",
" }",
"",
" @TypeMigration(",
" of = Util.class,",
" unmigratedMethods = {\"Util()\", \"publicStringMethodWithArg(int)\"})",
" @TypeMigration(of = Util.class, unmigratedMethods = \"publicStringMethodWithArg(int)\")",
" class AnnotatedWithIncorrectMethodReference {",
" @BeforeTemplate",
" void before() {",
" new Util().publicStringMethodWithArg(\"1\");",
" Util.publicStaticVoidMethod();",
" Util.publicStaticIntMethod2();",
" }",
Expand All @@ -243,6 +253,7 @@ void replacement() {
" @BeforeTemplate",
" void before() {",
" new Util().publicStringMethodWithArg(1);",
" new Util().publicStringMethodWithArg(\"1\");",
" Util.publicStaticIntMethod2();",
" }",
" }",
Expand Down

0 comments on commit b969b95

Please sign in to comment.