Skip to content

Commit

Permalink
check that type is in fact a supertype
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Sep 28, 2023
1 parent 778447e commit af6ca1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nullaway/src/main/java/com/uber/nullaway/GenericsChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.util.stream.Collectors.joining;

import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.errorprone.VisitorState;
import com.google.errorprone.suppliers.Supplier;
import com.google.errorprone.suppliers.Suppliers;
Expand Down Expand Up @@ -723,7 +724,11 @@ private static Type getTypeForSymbol(Symbol symbol, VisitorState state) {
throw new RuntimeException(
"method should be inside a NewClassTree " + state.getSourceForNode(path.getLeaf()));
}
return getTreeType(newClassTree, state);
Type typeFromTree = getTreeType(newClassTree, state);
if (typeFromTree != null) {
Verify.verify(state.getTypes().isAssignable(symbol.type, typeFromTree));
}
return typeFromTree;
} else {
return symbol.type;
}
Expand Down

0 comments on commit af6ca1f

Please sign in to comment.