Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Checking whether type inference in Java will allow cyclic inferred types; comples with jdk 1.7 but not 1.6.
abstract class Nope<T extends Nope<T>> {
private Nope() {}
class NopeElim {
public<T extends Nope<T>> void ohNo() {
System.out.println("Is there a way to call this");
public class TestCyclicTypeInference {
public static void main (String[] args) {
NopeElim elim = new NopeElim();
// Can you find a T such that elim.<T>ohNo() typechecks?
// No, but this does:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment