Skip to content

CFI crashes on generic conditional expression in nested generic class #474

Description

@aosen-xiong

Minimal Reproducer

SmallRepro.java:

import java.util.ArrayList;
import java.util.List;

class SmallRepro<ID, T> {
    static class Box<ID, T> {}

    static class Worker<ID, T> {
        List<Box<ID, T>> f(List<Box<ID, T>> xs) {
            return xs == null ? new ArrayList<>() : xs;
        }
    }
}

Command

./gradlew dist --console=plain --quiet
./scripts/inference --hacks=true --mode INFER \
  --checker nninf.NninfChecker \
  --solver checkers.inference.solver.MaxSat2TypeSolver \
  SmallRepro.java

Error

Error in AnnotatedTypeMirror.fromExpression(InferenceAnnotatedTypeFactory, condExpr#num0):
Cannot invoke "com.sun.source.util.TreePath.getParentPath()"
because the return value of
"checkers.inference.VariableAnnotator.expensiveBackupGetPath(...)" is null

Expected
Inference should not crash on this valid Java program. If CFI cannot recover a TreePath, it should use a fallback location or report a controlled diagnostic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions