Skip to content

Commit

Permalink
Warn on boxed primitive usage in locks.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=297665455
  • Loading branch information
dgfried authored and cpovirk committed Feb 28, 2020
1 parent 989bc53 commit 9a3bc86
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ public static <T extends Tree> Matcher<T> isPrimitiveOrBoxedPrimitiveType() {
(type, state) -> state.getTypes().unboxedTypeOrType(type).isPrimitive());
}

/** Matches an AST node if its type is a boxed primitive type. */
public static Matcher<ExpressionTree> 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 <T extends Tree> Enclosing.Block<T> enclosingBlock(Matcher<BlockTree> matcher) {
return new Enclosing.Block<>(matcher);
Expand Down Expand Up @@ -1283,6 +1290,7 @@ public static boolean isThrowingFunctionalInterface(Type clazzType, VisitorState
.filter(Objects::nonNull)
.collect(toImmutableSet()));


private static class IsDirectImplementationOf extends ChildMultiMatcher<ClassTree, Tree> {
public IsDirectImplementationOf(Matcher<Tree> classMatcher) {
super(MatchType.AT_LEAST_ONE, classMatcher);
Expand Down

0 comments on commit 9a3bc86

Please sign in to comment.