Skip to content

Commit

Permalink
Automated rollback of commit 5da8e9a.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Just testing

*** Original change description ***

Fix binary compatibility issues when building on JDK 17 and running on JDK 11, and prepare to add test coverage for that configuration

Thanks to Stephan202's suggestion in #3895 (comment)

#3895

PiperOrigin-RevId: 530962639
  • Loading branch information
cushon authored and Error Prone Team committed May 10, 2023
1 parent c2b71f9 commit 9c5b3b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1141,17 +1141,9 @@ public static List<MethodTree> getConstructors(ClassTree classTree) {
return constructors;
}

/**
* A wrapper for {@link Symbol#getEnclosedElements} to avoid binary compatibility issues for
* covariant overrides in subtypes of {@link Symbol}.
*/
public static List<Symbol> getEnclosedElements(Symbol symbol) {
return symbol.getEnclosedElements();
}

/** Returns the list of all constructors defined in the class. */
public static ImmutableList<MethodSymbol> getConstructors(ClassSymbol classSymbol) {
return getEnclosedElements(classSymbol).stream()
return classSymbol.getEnclosedElements().stream()
.filter(Symbol::isConstructor)
.map(e -> (MethodSymbol) e)
.collect(toImmutableList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static com.google.errorprone.matchers.Matchers.instanceMethod;
import static com.google.errorprone.matchers.Matchers.staticMethod;
import static com.google.errorprone.util.ASTHelpers.getDeclaredSymbol;
import static com.google.errorprone.util.ASTHelpers.getEnclosedElements;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
import static com.google.errorprone.util.ASTHelpers.isSubtype;
import static com.sun.source.tree.Tree.Kind.CLASS;
Expand Down Expand Up @@ -213,9 +212,9 @@ private static FactoryMethodName tryFindFactory(
ImmutableSet<MethodSymbol> factories =
concat(
// The class that assertThat is declared in:
getEnclosedElements(assertThatSymbol.owner).stream(),
assertThatSymbol.owner.getEnclosedElements().stream(),
// The Subject class (possibly the same; if so, toImmutableSet() will deduplicate):
getEnclosedElements(assertThatSymbol.getReturnType().asElement()).stream())
assertThatSymbol.getReturnType().asElement().getEnclosedElements().stream())
.filter(s -> s instanceof MethodSymbol)
.map(s -> (MethodSymbol) s)
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static com.google.errorprone.matchers.Matchers.argument;
import static com.google.errorprone.matchers.Matchers.classLiteral;
import static com.google.errorprone.matchers.method.MethodMatchers.staticMethod;
import static com.google.errorprone.util.ASTHelpers.getEnclosedElements;
import static com.google.errorprone.util.ASTHelpers.getSymbol;
import static com.google.errorprone.util.ASTHelpers.getType;
import static com.google.errorprone.util.ASTHelpers.isSameType;
Expand Down Expand Up @@ -124,7 +123,7 @@ public boolean matches(ExpressionTree tree, VisitorState state) {
return true;
}

for (Symbol enclosedSymbol : getEnclosedElements(classSymbol)) {
for (Symbol enclosedSymbol : classSymbol.getEnclosedElements()) {
if (!enclosedSymbol.isConstructor()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ CompilationResult compile() throws IOException {
diagnosticCollector,
javacopts,
/* classes= */ Collections.<String>emptyList(),
fileManager.getJavaFileObjects(sources.toArray(new Path[0])))
fileManager.getJavaFileObjectsFromPaths(sources))
.call();

return CompilationResult.create(
Expand Down

0 comments on commit 9c5b3b4

Please sign in to comment.