Skip to content

Handle enhanced for loops properly in JSpecify mode #1581

Description

@msridhar

Example:

void test(List<@Nullable String> l) {
  for (String s: l) {
    s.hashCode(); // should report a warning
  }
  for (var s: l) {
    s.hashCode(); // should report a warning
  }
}
interface Foo<T extends @Nullable Object> { T get(); }
void test2(List<Foo<@Nullable String>> l) {
  for (var foo: l) {
    foo.get().hashCode(); // should report a warning
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    jspecifyRelated to support for jspecify standard (see jspecify.dev)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions