Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
armughan11 committed Jun 22, 2024
1 parent cc3dee3 commit 0d0a3ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.errorprone.suppliers.Supplier;
import com.google.errorprone.suppliers.Suppliers;
import com.google.errorprone.util.ASTHelpers;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Type;
Expand Down Expand Up @@ -507,7 +508,6 @@ public TransferResult<Nullness, NullnessStore> visitAssignment(
Node rhs = node.getExpression();
Nullness value = values(input).valueOfSubNode(rhs);
Node target = node.getTarget();

if (target instanceof LocalVariableNode
&& !castToNonNull(ASTHelpers.getType(target.getTree())).isPrimitive()) {
LocalVariableNode localVariableNode = (LocalVariableNode) target;
Expand Down Expand Up @@ -791,8 +791,14 @@ public TransferResult<Nullness, NullnessStore> visitArrayAccess(
Nullness resultNullness;
// Unsoundly assume @NonNull, except in JSpecify mode where we check the type
if (config.isJSpecifyMode()) {
Symbol arraySymbol = ASTHelpers.getSymbol(node.getArray().getTree());
Symbol arraySymbol;
boolean isElementNullable = false;
ExpressionTree arrayExpr = node.getArrayExpression();
if (arrayExpr != null) {
arraySymbol = ASTHelpers.getSymbol(arrayExpr);
} else {
arraySymbol = ASTHelpers.getSymbol(node.getArray().getTree());
}
if (arraySymbol != null) {
isElementNullable = NullabilityUtil.isArrayElementNullable(arraySymbol, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.errorprone.CompilationTestHelper;
import com.uber.nullaway.NullAwayTestsBase;
import java.util.Arrays;
import org.junit.Ignore;
import org.junit.Test;

public class ArrayTests extends NullAwayTestsBase {
Expand Down Expand Up @@ -492,7 +491,6 @@ public void loopVariableIndex() {
}

@Test
@Ignore("for-each handling needs to be fixed; see https://github.com/uber/NullAway/issues/983")
public void forEachLoop() {
makeHelper()
.addSourceLines(
Expand All @@ -506,8 +504,6 @@ public void forEachLoop() {
" if (s != null) {",
" s.toString();",
" }",
" }",
" for (String s : fizz) {",
" // BUG: Diagnostic contains: dereferenced expression s is @Nullable",
" s.toString();",
" }",
Expand Down

0 comments on commit 0d0a3ef

Please sign in to comment.