+1 to what has already been said. It's up to each code implementor to ensure that the proper functionality is in place, and up to reach consumer of code that others have written to ensure that code does what they want.
To offer concrete proof that this isn't possible in Java:
Suppose there were a way to enforce what you're asking for
Code:
public interface A<T> /* magic that requires subclass of A to use itself as the type parameter */ {
public T interpolate(T a);
}
Since there's no way in Java to require a subclass to be final, nothing prevents a malicious user from doing the following
Code:
class B extends A<B> {
public B interpolate(B a){
// implementation
}
}
class C extends B {}
at this point, C is equivalent to
Code:
class C extends A<B>
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor