diff --git a/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java b/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java index 7d963017242..95647f656a1 100644 --- a/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java +++ b/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java @@ -466,6 +466,13 @@ public static Matcher isPrimitiveOrBoxedPrimitiveType() { (type, state) -> state.getTypes().unboxedTypeOrType(type).isPrimitive()); } + /** Matches an AST node if its type is a boxed primitive type. */ + public static Matcher isBoxedPrimitiveType() { + return typePredicateMatcher( + (type, state) -> + !state.getTypes().isSameType(state.getTypes().unboxedType(type), Type.noType)); + } + /** Matches an AST node which is enclosed by a block node that matches the given matcher. */ public static Enclosing.Block enclosingBlock(Matcher matcher) { return new Enclosing.Block<>(matcher); @@ -1283,6 +1290,7 @@ public static boolean isThrowingFunctionalInterface(Type clazzType, VisitorState .filter(Objects::nonNull) .collect(toImmutableSet())); + private static class IsDirectImplementationOf extends ChildMultiMatcher { public IsDirectImplementationOf(Matcher classMatcher) { super(MatchType.AT_LEAST_ONE, classMatcher);