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 1491b4dbd81..0b762e849bb 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 @@ -535,7 +535,7 @@ public static Type getReturnType(ExpressionTree expressionTree) { */ public static @Nullable Type getResultType(ExpressionTree expressionTree) { Type type = ASTHelpers.getType(expressionTree); - return type == null ? null : Optional.ofNullable(type.getReturnType()).orElse(type); + return type == null ? null : (type.getReturnType() == null ? type : type.getReturnType()); } /**