Bugfix für duplicate methods
This commit is contained in:
parent
bb5a4e8580
commit
32ab198f9e
@ -167,12 +167,14 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
public void visit(Method method) {
|
public void visit(Method method) {
|
||||||
// TODO: check if the method is static => if static then the first param will be stored in pos 0
|
// TODO: check if the method is static => if static then the first param will be stored in pos 0
|
||||||
// else it will be stored in pos 1 and this will be stored in pos 0
|
// else it will be stored in pos 1 and this will be stored in pos 0
|
||||||
|
String retType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
String methParamTypes = retType+method.name+"%%";
|
||||||
method.getParameterList().accept(this);
|
method.getParameterList().accept(this);
|
||||||
String methParamTypes = method.name+";";
|
|
||||||
Iterator<FormalParameter> itr = method.getParameterList().iterator();
|
Iterator<FormalParameter> itr = method.getParameterList().iterator();
|
||||||
while(itr.hasNext()) {
|
while(itr.hasNext()) {
|
||||||
FormalParameter fp = itr.next();
|
FormalParameter fp = itr.next();
|
||||||
methParamTypes = methParamTypes+ resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(methodNameAndParamsT.contains(methParamTypes)) {
|
if(methodNameAndParamsT.contains(methParamTypes)) {
|
||||||
|
@ -44,14 +44,14 @@ public class OverloadingTest {
|
|||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method meth = classToTest.getDeclaredMethod("test", classToTest);
|
Method meth = classToTest.getDeclaredMethod("test", classToTest);
|
||||||
String res = (String) meth.invoke(instanceOfClass, instanceOfClass);
|
String res = (String) meth.invoke(instanceOfClass, instanceOfClass);
|
||||||
assertEquals("\"Overloading\"", res);
|
assertEquals("Overloading", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method meth = classToTest.getDeclaredMethod("test", classOL2);
|
Method meth = classToTest.getDeclaredMethod("test", classOL2);
|
||||||
String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2);
|
String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2);
|
||||||
assertEquals("\"Overloading2\"", res);
|
assertEquals("Overloading2", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user