Unrelated return types
Aug 8, 2010       12:36 pm

There's no shortage of Java things to be frustrated about.

public class Fail {

  static interface A { }
  static interface B { }
  static interface C extends A, B {}

  static interface D { A x(); }
  static interface E { B x(); }
  static interface F extends D, E { C x(); }

}

I see no legitimate reason why this should not compile. But javac disagrees:

Fail.java:9: types Fail.E and Fail.D are incompatible; both define x(), but with unrelated return types

IntelliJ IDEA, however, doesn't see a problem with this code. Although I agree with it, I've submitted a bug report.

new comment >
Re: Unrelated return types
by Anonymous on Aug 9, 2010, 3:35 pm
I can only imagine this is a holdover from before Java supported covariant return overloading?