I've got a compile error which has me a bit stumped. It says:
TTTree<K,V>
cannot be converted to TTTree<K,V>
at the marked line of code below.
public abstract class TTTree<K extends Comparable<K>, V> {
public abstract TTTree<K, V> put(K k, V v);
private static <K extends Comparable<K>, V> TTTree<K, V> leaf(K k, V v) { return null; }
private static class Leaf<K extends Comparable<K>, V> extends TTTree<K, V> {
private final K k = null;
private final V v = null;
@Override
public TTTree<K, V> put(K ik, V iv) {
TTTree<K, V> newLeaf = leaf(ik, iv);
return node(newLeaf, k, this); // <---- !!!! ERROR !!!!
}
};
private TTTree<K, V> node(TTTree<K, V> l, K k, TTTree<K, V> r) {
return null;
}
}
Seems like this should work, so why doesn't the compiler like it? And what could I do to fix the error (I guess I could convert everything to raw types, but that's a bit too drastic).
PS: Sample code cut down to 'bare minimum' while still producing the error.
PS2: Compiling using Java 8 compiler.