From 918fa9e0b80487a9081d7a5206f064a104564283 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sun, 3 Dec 2023 19:42:44 -0800 Subject: [PATCH] Don't compute element unless necessary --- .../checkerframework/javacutil/ElementUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java b/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java index 099464a546c..bfaaacd68cb 100644 --- a/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java +++ b/javacutil/src/main/java/org/checkerframework/javacutil/ElementUtils.java @@ -939,12 +939,19 @@ public static boolean matchesElement( return true; } - /** Returns true if the given element is, or overrides, method. */ + /** + * Returns true if the given element is, or overrides, {@code method}. + * + * @param questioned an element that might override {@code method} + * @param method a method that might be overridden + * @param env the processing environment + * @return true if {@code questioned} is, or overrides, {@code method} + */ public static boolean isMethod( ExecutableElement questioned, ExecutableElement method, ProcessingEnvironment env) { - TypeElement enclosing = (TypeElement) questioned.getEnclosingElement(); return questioned.equals(method) - || env.getElementUtils().overrides(questioned, method, enclosing); + || env.getElementUtils() + .overrides(questioned, method, (TypeElement) questioned.getEnclosingElement()); } /**