Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
another fix
  • Loading branch information
msridhar committed Apr 6, 2025
commit 80ae0171f680dcd184cdf3fe53e78b71cf4cdc8d
9 changes: 9 additions & 0 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ public Description matchNewClass(NewClassTree tree, VisitorState state) {
if (methodSymbol == null) {
throw new RuntimeException("not expecting unresolved method here");
}
ExpressionTree enclosingExpression = tree.getEnclosingExpression();
if (enclosingExpression != null) {
// technically this is not a dereference; there is a requireNonull() call in the
// bytecode. but it's close enough for error reporting
Description desc = matchDereference(enclosingExpression, tree, state);
if (!desc.equals(Description.NO_MATCH)) {
state.reportMatch(desc);
}
}
List<? extends ExpressionTree> actualParams = tree.getArguments();
if (tree.getClassBody() != null) {
// invoking constructor of anonymous class
Expand Down
7 changes: 6 additions & 1 deletion nullaway/src/test/java/com/uber/nullaway/CoreTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1141,9 +1141,14 @@ public void issue1888() {
.addSourceLines(
"Outer.java",
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"class Outer {",
" class Inner {}",
" static Inner f(Outer outer) {",
" static Inner testNegative(Outer outer) {",
" return outer.new Inner() {};",
" }",
" static Inner testPositive(@Nullable Outer outer) {",
" // BUG: Diagnostic contains: dereferenced expression outer is @Nullable",
" return outer.new Inner() {};",
" }",
"}")
Expand Down
Loading