J
John C. Bollinger
Neither version 1.5.0_06 of Sun's compiler nor version 3.1.1 of
Eclipse's will compile the following code, but I can't figure out what's
wrong with it:
====
package test;
public class TestTypeBounds {
public void foo(Bar<? extends Foo, Baz<? extends Foo>> bar) {
}
public <T extends Foo> void doFoo(Bar<T, Baz<? extends T>> bar) {
foo(bar); // <=== incompatible types here (?)
}
}
class Foo {}
class Bar <X, Y> {}
class Baz <Z> {}
====
Both compilers complain about incompatible types in the invocation of
foo(). Eclipse's compiler seems to have fewer bugs related to
parameterized types than does Sun's (0 vs. 2 on my personal scorecard,
before this), but when both compilers reject the code it's a pretty good
sign that the code is wrong. For the life of me, however, I don't see
the problem. Does anyone else see anything wrong?
Eclipse's will compile the following code, but I can't figure out what's
wrong with it:
====
package test;
public class TestTypeBounds {
public void foo(Bar<? extends Foo, Baz<? extends Foo>> bar) {
}
public <T extends Foo> void doFoo(Bar<T, Baz<? extends T>> bar) {
foo(bar); // <=== incompatible types here (?)
}
}
class Foo {}
class Bar <X, Y> {}
class Baz <Z> {}
====
Both compilers complain about incompatible types in the invocation of
foo(). Eclipse's compiler seems to have fewer bugs related to
parameterized types than does Sun's (0 vs. 2 on my personal scorecard,
before this), but when both compilers reject the code it's a pretty good
sign that the code is wrong. For the life of me, however, I don't see
the problem. Does anyone else see anything wrong?