From 46286615b3b956fa04005200539df5ff04906606 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Fri, 8 Sep 2023 13:00:08 -0400 Subject: [PATCH] Update to errorprone 2.21.1 (#564) --- build.gradle | 2 +- .../reflection/DefaultReflectionResolver.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 34bc638469c..3c1cb5344a5 100644 --- a/build.gradle +++ b/build.gradle @@ -863,7 +863,7 @@ subprojects { // * Temporarily comment out "-Werror" elsewhere in this file // * Repeatedly run `./gradlew clean compileJava` and fix all errors // * Uncomment "-Werror" - ext.errorproneVersion = '2.20.0' + ext.errorproneVersion = '2.21.1' errorprone group: 'com.google.errorprone', name: 'error_prone_core', version: errorproneVersion // TODO: it's a bug that annotatedlib:guava requires the error_prone_annotations dependency. diff --git a/framework/src/main/java/org/checkerframework/common/reflection/DefaultReflectionResolver.java b/framework/src/main/java/org/checkerframework/common/reflection/DefaultReflectionResolver.java index 8c0161dbdf1..b526e9bf684 100644 --- a/framework/src/main/java/org/checkerframework/common/reflection/DefaultReflectionResolver.java +++ b/framework/src/main/java/org/checkerframework/common/reflection/DefaultReflectionResolver.java @@ -525,7 +525,7 @@ private List getMethodSymbolsfor( List result = new ArrayList<>(); ClassSymbol classSym = (ClassSymbol) sym; while (classSym != null) { - for (Symbol s : classSym.getEnclosedElements()) { + for (Symbol s : getEnclosedElements(classSym)) { // check all member methods if (s.getKind() == ElementKind.METHOD) { // Check for method name and number of arguments @@ -568,11 +568,11 @@ private List getConstructorSymbolsfor( } // TODO: Should this be used instead of the below?? - ElementFilter.constructorsIn(symClass.getEnclosedElements()); + ElementFilter.constructorsIn(getEnclosedElements(symClass)); // The common case is probably that there is one constructor of the given parameter length. List result = new ArrayList<>(2); - for (Symbol s : symClass.getEnclosedElements()) { + for (Symbol s : getEnclosedElements(symClass)) { // Check all constructors if (s.getKind() == ElementKind.CONSTRUCTOR) { // Check for number of parameters @@ -610,6 +610,18 @@ private Symbol getSymbol(String className, Env env, Names names, Re } } + /** + * Determine the enclosed elements for an element. This wrapper is useful to avoid a signature + * change in the called method. + * + * @param sym the element + * @return the enclosed elements + */ + @SuppressWarnings("ASTHelpersSuggestions") // Use local helper. + private static List getEnclosedElements(Symbol sym) { + return sym.getEnclosedElements(); + } + /** * Build lub of the two types (represented by sets {@code set1} and {@code set2}) using the * provided AnnotatedTypeFactory.