Taking the super methods parameters should only happen for the types, fix #306
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m23s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m23s
This commit is contained in:
parent
e07521d9b6
commit
7cb0e9dbb7
13
resources/bytecode/javFiles/Bug306.jav
Normal file
13
resources/bytecode/javFiles/Bug306.jav
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class Base {
|
||||||
|
m(List<Integer> a) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bug306 extends Base {
|
||||||
|
@Override
|
||||||
|
m(List<Integer> b) {
|
||||||
|
b.add(1);
|
||||||
|
}
|
||||||
|
}
|
@ -52,7 +52,7 @@ public class ASTToTargetAST {
|
|||||||
return converter.result;
|
return converter.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
record Generics(JavaGenerics javaGenerics, TxGenerics txGenerics) {
|
public record Generics(JavaGenerics javaGenerics, TxGenerics txGenerics) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ public class ASTToTargetAST {
|
|||||||
if (superMethod.isPresent()) {
|
if (superMethod.isPresent()) {
|
||||||
// If we find a super method to override, use its parameters and return types
|
// If we find a super method to override, use its parameters and return types
|
||||||
returnType = convert(superMethod.get().getReturnType(), this.generics.javaGenerics);
|
returnType = convert(superMethod.get().getReturnType(), this.generics.javaGenerics);
|
||||||
params = convert(superMethod.get().getParameterList(), this.generics.javaGenerics);
|
params = convert(superMethod.get().getParameterList(), method.getParameterList(), this.generics.javaGenerics);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MethodParameter> finalParams = params;
|
List<MethodParameter> finalParams = params;
|
||||||
@ -404,6 +404,15 @@ public class ASTToTargetAST {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<MethodParameter> convert(ParameterList superList, ParameterList paraList, JavaGenerics generics) {
|
||||||
|
var list = new ArrayList<MethodParameter>();
|
||||||
|
for (var i = 0; i < paraList.getFormalparalist().size(); i++) {
|
||||||
|
var param = paraList.getParameterAt(i);
|
||||||
|
list.add(new MethodParameter((TargetPattern) convert(param)).withType(convert(superList.getParameterAt(i).getType(), generics)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
protected TargetSwitch.Case convert(SwitchBlock block) {
|
protected TargetSwitch.Case convert(SwitchBlock block) {
|
||||||
return new TargetSwitch.Case(block.getLabels().stream().map(this::convert).toList(), convert((Block) block), block.isExpression);
|
return new TargetSwitch.Case(block.getLabels().stream().map(this::convert).toList(), convert((Block) block), block.isExpression);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,6 @@ implements IFiniteClosure {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(args);
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,4 +995,11 @@ public class TestComplete {
|
|||||||
var clazz = classFiles.get("Bug301");
|
var clazz = classFiles.get("Bug301");
|
||||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug306() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug306.jav");
|
||||||
|
var clazz = classFiles.get("Bug306");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user