Last active
August 29, 2015 14:02
-
-
Save oleg/7d28c1920d46ffdde354 to your computer and use it in GitHub Desktop.
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
package sample; | |
class Outer<T> { | |
class Inner<S> { | |
S s; | |
} | |
} | |
public class Sample { | |
public static void main(String... args) { | |
//ok | |
Outer<Integer>.Inner<String> one = null; | |
//compilation error: Improper formed type; some type arguments are missing | |
Outer<Integer>.Inner two = null; | |
//compilation error: Type arguments given on a raw type | |
Outer.Inner<String> three = null; | |
} | |
} |
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
package sample; | |
import java.util.List; | |
class NonGenericChild extends Generic<String> { } | |
class GenericChild<E> extends Generic<String> { } | |
class Generic<T> { List<T> list() { return null; } } | |
public class Sample { | |
public static void main(String[] args) { | |
// no warning | |
List<String> r1 = new NonGenericChild().list(); | |
// no warning | |
List<String> r2 = new GenericChild<Integer>().list(); | |
// wtf, unchecked assignment warning? | |
// why is parent's generic type erased? | |
List<String> r3 = new GenericChild().list(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment