Skip to content

Commit

Permalink
Drop pre-JDK 11 logic from Refaster's Inliner class
Browse files Browse the repository at this point in the history
Fixes #3441

COPYBARA_INTEGRATE_REVIEW=#3441 from PicnicSupermarket:improvement/simplify-refaster-inliner 725e5cf
PiperOrigin-RevId: 473657497
  • Loading branch information
Stephan202 authored and Error Prone Team committed Sep 12, 2022
1 parent 644f3da commit 21ab00e
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions core/src/main/java/com/google/errorprone/refaster/Inliner.java
Expand Up @@ -227,26 +227,11 @@ public TypeVar inlineAsVar(UTypeVar var) throws CouldNotResolveImportException {
sym.type = typeVar;
typeVarCache.put(var.getName(), typeVar);
// Any recursive uses of var will point to the same TypeVar object generated above.
setUpperBound(typeVar, var.getUpperBound().inline(this));
typeVar.setUpperBound(var.getUpperBound().inline(this));
typeVar.lower = var.getLowerBound().inline(this);
return typeVar;
}

private static void setUpperBound(TypeVar typeVar, Type bound) {
// https://bugs.openjdk.java.net/browse/JDK-8193367
try {
TypeVar.class.getMethod("setUpperBound", Type.class).invoke(typeVar, bound);
return;
} catch (ReflectiveOperationException e) {
// continue below
}
try {
TypeVar.class.getField("bound").set(typeVar, bound);
} catch (ReflectiveOperationException e) {
throw new LinkageError(e.getMessage(), e);
}
}

Type inlineTypeVar(UTypeVar var) throws CouldNotResolveImportException {
Optional<TypeWithExpression> typeVarBinding = getOptionalBinding(var.key());
if (typeVarBinding.isPresent()) {
Expand Down

0 comments on commit 21ab00e

Please sign in to comment.