Skip to content

Commit

Permalink
Make Matchers.toType generic
Browse files Browse the repository at this point in the history
MOE_MIGRATED_REVID=142193545
  • Loading branch information
emma-borhanian authored and nick-someone committed Dec 22, 2016
1 parent 8caba68 commit 6b3974e
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -1160,14 +1160,14 @@ static Matcher<Tree> isSymbol(java.lang.Class<? extends Symbol> symbolClass) {
}

/**
* Converts the given matcher to one that can be applied to any tree but is only executed when
* run on a tree of {@code type} and returns {@code false} for all other tree types.
* Converts the given matcher to one that can be applied to any tree but is only executed when run
* on a tree of {@code type} and returns {@code false} for all other tree types.
*/
public static <T extends Tree> Matcher<Tree> toType(
final Class<T> type, final Matcher<? super T> matcher) {
return new Matcher<Tree>() {
public static <S extends Tree, T extends Tree> Matcher<T> toType(
final Class<S> type, final Matcher<? super S> matcher) {
return new Matcher<T>() {
@Override
public boolean matches(Tree tree, VisitorState state) {
public boolean matches(T tree, VisitorState state) {
return type.isInstance(tree) && matcher.matches(type.cast(tree), state);
}
};
Expand Down

0 comments on commit 6b3974e

Please sign in to comment.