Issue1381
Created on 2009-06-18.15:34:27 by sreimers, last changed 2009-06-30.06:10:17 by cgroves.
msg4819 (view) |
Author: Sven Reimers (sreimers) |
Date: 2009-06-18.15:34:27 |
|
Multiple Inheritance and Method Overloading resolves wrong metnod
|
msg4820 (view) |
Author: Sven Reimers (sreimers) |
Date: 2009-06-18.15:37:35 |
|
Having two interfaces providing two different overloads for a method
with different single argument, leads the interpreter to resolve the
wrong method (he seems to find only one, not both), so that my script fails.
Debugging through the process, it seems that the interpreter selects
just one interface and tries to resolve the method name based on this
interface and ignore the other (just my 2$c)
If necessary I maybe could come up with an example code showing the
problem - the original code is closed - sorry.
|
msg4821 (view) |
Author: Sven Reimers (sreimers) |
Date: 2009-06-18.15:38:55 |
|
this worked with latest 2.2x versions and IIRC it still worked with the
2.5 alpha release
|
msg4859 (view) |
Author: Charlie Groves (cgroves) |
Date: 2009-06-29.02:26:43 |
|
In r6500 I added a test that calls all the methods on Implementation in the following Java code
from Python:
public class DisagreeingInterfaceOverrides {
public interface StringArg {
String call(String arg);
}
public interface IntArg {
String call(int arg);
}
public interface ListArg {
String call(List<Object> arg);
}
public interface ArrayListArg {
String call(List<Object> arg);
}
public static class Implementation implements StringArg, IntArg, ListArg, ArrayListArg {
public String call(String arg) {
return "String";
}
public String call(int arg) {
return "int";
}
public String call(List<Object> arg) {
return "List";
}
public String call(ArrayList<Object> arg) {
return "ArrayList";
}
}
}
When using the type specified for each method, I got the proper String back from that method.
Could you attach some code that causes the problem? I'm not able to reproduce it from your
description.
|
msg4861 (view) |
Author: Sven Reimers (sreimers) |
Date: 2009-06-29.15:19:15 |
|
Hopefully this example code will show the problem:
public class DisagreeingInterfaceOverrides {
public interface IntArg {
String call(int arg);
}
//
// public interface ListArg {
//
// String call(List<Object> arg);
// }
//
// public interface ArrayListArg {
//
// String call(List<Object> arg);
// }
public interface ClassArg {
String call(final Class arg);
}
public interface StringArg extends ClassArg{
String call(final String name);
}
public static abstract class AbstractImplementation implements
StringArg, IntArg{
public String call(final Class arg) {
return "Class";
}
}
public static abstract class AbstractExtImplementation extends
AbstractImplementation{
}
public static class Implementation extends AbstractExtImplementation
implements StringArg{
public final String call(final String name) {
return "String";
}
public String call(int arg) {
return "int";
}
//string working
//class working
//int working
}
public static class SmartImpl1 extends Implementation implements
StringArg{
//string working
//class working
//int working
}
public static class SmartImpl2 extends Implementation implements
ClassArg{
//string not working
//class working
//int not working
}
public static class SmartImpl3 extends Implementation implements
ClassArg, StringArg{
//string not working
//class working
//int not working
}
public static class SmartImpl4 extends Implementation implements
StringArg, ClassArg{
//string working
//class working
//int working
}
}
|
msg4864 (view) |
Author: Charlie Groves (cgroves) |
Date: 2009-06-30.06:10:16 |
|
Thanks for the example code! I didn't realize redundant interface
declarations were involved. Should be fixed in r6504.
|
|
Date |
User |
Action |
Args |
2009-06-30 06:10:17 | cgroves | set | status: open -> closed resolution: fixed messages:
+ msg4864 |
2009-06-29 15:19:15 | sreimers | set | messages:
+ msg4861 |
2009-06-29 02:26:44 | cgroves | set | messages:
+ msg4859 |
2009-06-18 16:56:16 | cgroves | set | assignee: cgroves nosy:
+ cgroves |
2009-06-18 16:10:43 | sreimers | set | versions:
+ 2.5.1, 25rc4, - 2.5b0 |
2009-06-18 15:38:55 | sreimers | set | messages:
+ msg4821 |
2009-06-18 15:37:36 | sreimers | set | messages:
+ msg4820 title: Multiple inheritance andMethod Overloading resolves wrong method -> Multiple inheritance and method overloading resolves wrong method |
2009-06-18 15:34:27 | sreimers | create | |
|