Skip to content

Capture conversion forgets annotation #3754

@mernst

Description

@mernst

For this code:

import org.checkerframework.checker.nullness.qual.Nullable;

class Issue3754 {
  interface Supplier<T extends @Nullable Object, U extends T> {
    U get();
  }

  Object x(Supplier<? extends Object, ?> bar) {
    return bar.get();
  }
}

the Nullness Checker issues this warning:

Issue3754.java:9: error: [return.type.incompatible] incompatible types in return.
    return bar.get();
                  ^
  type of expression: ? extends capture#519 of ? extends java.lang.Object extends @Initialized @Nullable Object
  method return type: @Initialized @NonNull Object

I think the code should type-check.

Metadata

Metadata

Assignees

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