Skip to content

False positive regarding @KeyFor #181

@d367wang

Description

@d367wang

The following test case works with https://github.com/typetools/checker-framework, while gets false positive with the opprop version.

import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.*;

class A {

    public HashMap<Integer, Date> call_hashmap = new HashMap<>();
    public HashMap<Integer, Date> getMap() {return call_hashmap;}

}

class NonNullMapValue {

    public void process_unmatched_procedure_entries(A a) {
        for (Integer i : a.getMap().keySet()) {
            @NonNull Date d = a.getMap().get(i);
        }
    }
}

gets false positive as

case/KeyForDemo.java:33: error: [assignment.type.incompatible] incompatible types in assignment.
@nonnull Date d = a.getMap().get(i);
^
found : @initialized @nullable Date
required: @UnknownInitialization @nonnull Date
1 error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions