Bugfix für duplicate methods

This commit is contained in:
Fayez Abu Alia 2018-03-28 14:57:36 +02:00
parent bb5a4e8580
commit 32ab198f9e
2 changed files with 6 additions and 4 deletions

View File

@ -167,12 +167,14 @@ public class BytecodeGen implements ASTVisitor {
public void visit(Method method) {
// 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
String retType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
String methParamTypes = retType+method.name+"%%";
method.getParameterList().accept(this);
String methParamTypes = method.name+";";
Iterator<FormalParameter> itr = method.getParameterList().iterator();
while(itr.hasNext()) {
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)) {

View File

@ -44,14 +44,14 @@ public class OverloadingTest {
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Method meth = classToTest.getDeclaredMethod("test", classToTest);
String res = (String) meth.invoke(instanceOfClass, instanceOfClass);
assertEquals("\"Overloading\"", res);
assertEquals("Overloading", res);
}
@Test
public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Method meth = classToTest.getDeclaredMethod("test", classOL2);
String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2);
assertEquals("\"Overloading2\"", res);
assertEquals("Overloading2", res);
}
}