From 7e6a7deb79142acd68cc55ee5bfdd80f03d80b3a Mon Sep 17 00:00:00 2001 From: Patrick Koenig Date: Sun, 3 Mar 2024 20:55:33 -0500 Subject: [PATCH] Add null check to hasDirectAnnotationWithSimpleName --- .../src/main/java/com/google/errorprone/util/ASTHelpers.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java b/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java index 7882a03e7ca..efde524e11a 100644 --- a/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java +++ b/check_api/src/main/java/com/google/errorprone/util/ASTHelpers.java @@ -1001,6 +1001,9 @@ private static Set directAnnotationsAmong( * annotation inheritance (see JLS 9.6.4.3). */ public static boolean hasDirectAnnotationWithSimpleName(Symbol sym, String simpleName) { + if (sym == null) { + return false; + } if (sym instanceof MethodSymbol) { return hasDirectAnnotationWithSimpleName((MethodSymbol) sym, simpleName); }