Created
May 11, 2018 06:07
-
-
Save filiphr/65828e0803147e3efca10efeef81f432 to your computer and use it in GitHub Desktop.
Confusing compiler warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is more noticeable during annotation processing when the return type for
getNumbers
is a list without type arguments.