Skip to content

Instantly share code, notes, and snippets.

@filiphr
Created May 11, 2018 06:07
Show Gist options
  • Save filiphr/65828e0803147e3efca10efeef81f432 to your computer and use it in GitHub Desktop.
Save filiphr/65828e0803147e3efca10efeef81f432 to your computer and use it in GitHub Desktop.
Confusing compiler warning
import java.util.List;
public class Main {
public static void main(String[] args) {
Foo foo = new Foo();
// Why does the compiler complain about an unchecked assignment, because foo is raw?
List<Integer> numbers = foo.getNumbers();
}
public static class Foo<T> {
public T getValue() {
return null;
}
public List<Integer> getNumbers() {
return null;
}
}
}
@filiphr
Copy link
Author

filiphr commented May 11, 2018

The problem is more noticeable during annotation processing when the return type for getNumbers is a list without type arguments.

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