From db6459d13b067f7801d83f07bea17bf41d372a4e Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Fri, 14 Oct 2022 13:10:23 -0700 Subject: [PATCH] Add a null-check to work around https://github.com/google/error-prone/issues/3484 PiperOrigin-RevId: 481216285 --- .../main/java/com/google/errorprone/refaster/UMatches.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/google/errorprone/refaster/UMatches.java b/core/src/main/java/com/google/errorprone/refaster/UMatches.java index d13082e19d3..ac1cefcc279 100644 --- a/core/src/main/java/com/google/errorprone/refaster/UMatches.java +++ b/core/src/main/java/com/google/errorprone/refaster/UMatches.java @@ -95,7 +95,11 @@ static T makeMatcher(Class klass) { static VisitorState makeVisitorState(Tree target, Unifier unifier) { Context context = unifier.getContext(); + VisitorState state = new VisitorState(context); TreePath path = TreePath.getPath(context.get(JCCompilationUnit.class), target); - return new VisitorState(context).withPath(path); + if (path != null) { + state = state.withPath(path); + } + return state; } }