Add bug for #328
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Has been cancelled

This commit is contained in:
Daniel Holle 2024-04-29 10:25:01 +02:00
parent a5c314c5c5
commit c76ee355d8
6 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,8 @@
import java.lang.Integer;
import Bug328B;
public class Bug328 extends Bug328B {
public Bug328() {
super(1);
}
}

View File

@ -0,0 +1,3 @@
public class Bug328B {
public Bug328B(int a) {}
}

View File

@ -380,6 +380,7 @@ public class OutputGenerator implements ASTVisitor {
out.append("super("); out.append("super(");
superCall.arglist.accept(this); superCall.arglist.accept(this);
out.append(")"); out.append(")");
out.append(" Signature: " + superCall.signature);
} }
@Override @Override
@ -387,6 +388,7 @@ public class OutputGenerator implements ASTVisitor {
out.append("this("); out.append("this(");
thisCall.arglist.accept(this); thisCall.arglist.accept(this);
out.append(")"); out.append(")");
out.append(" Signature: " + thisCall.signature);
} }
@Override @Override

View File

@ -301,7 +301,7 @@ public class StatementToTargetExpression implements ASTVisitor {
var aSuper = converter.convert(superCall.receiver.getType()); var aSuper = converter.convert(superCall.receiver.getType());
var type = converter.convert(superCall.getType()); var type = converter.convert(superCall.getType());
var receiverName = new JavaClassName(converter.convert(superCall.receiver.getType()).name()); var receiverName = new JavaClassName(converter.convert(superCall.receiver.getType()).name());
var clazz = converter.compiler.getClass(converter.compiler.getClass(receiverName).getSuperClass().getName()); var clazz = converter.compiler.getClass(receiverName);
var signature = superCall.signatureArguments().stream().map(converter::convert).toList(); var signature = superCall.signatureArguments().stream().map(converter::convert).toList();
var method = converter.findConstructor(clazz, signature); var method = converter.findConstructor(clazz, signature);
var params = superCall.getArgumentList().getArguments().stream().map(converter::convert).toList(); var params = superCall.getArgumentList().getArguments().stream().map(converter::convert).toList();

View File

@ -592,6 +592,7 @@ public class TYPEStmt implements StatementVisitor {
var params = convertParams(ctor.getParameterList(), info); var params = convertParams(ctor.getParameterList(), info);
if (params.size() != superCall.arglist.getArguments().size()) continue; if (params.size() != superCall.arglist.getArguments().size()) continue;
var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(clazz, ctor), ctor.isInherited); var assumption = new MethodAssumption(null, new Void(new NullToken()), params, createTypeScope(clazz, ctor), ctor.isInherited);
System.out.println(params);
GenericsResolver resolver = getResolverInstance(); GenericsResolver resolver = getResolverInstance();
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(superCall, assumption, info, resolver); Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(superCall, assumption, info, resolver);
@ -682,6 +683,7 @@ public class TYPEStmt implements StatementVisitor {
extendsMethodConstraint.addAll(parameterContraints); extendsMethodConstraint.addAll(parameterContraints);
Set<Pair> methodSignatureConstraint = generatemethodSignatureConstraint(forMethod, assumption, info, resolver); Set<Pair> methodSignatureConstraint = generatemethodSignatureConstraint(forMethod, assumption, info, resolver);
System.out.println(methodSignatureConstraint);
//System.out.println("methodSignatureConstraint: " + methodSignatureConstraint); //System.out.println("methodSignatureConstraint: " + methodSignatureConstraint);
//System.out.println("methodConstraint: " + methodConstraint); //System.out.println("methodConstraint: " + methodConstraint);
@ -716,7 +718,7 @@ public class TYPEStmt implements StatementVisitor {
Set<Pair> ret = new HashSet<>(); Set<Pair> ret = new HashSet<>();
for (int i = 0; i < foMethod.arglist.getArguments().size(); i++) { for (int i = 0; i < foMethod.arglist.getArguments().size(); i++) {
System.out.println(foMethod.signature);
// Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params) // Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params)
ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT)); ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT));

View File

@ -1084,4 +1084,13 @@ public class TestComplete {
var res = clazz.getDeclaredMethod("convert", List.class).invoke(instance, list); var res = clazz.getDeclaredMethod("convert", List.class).invoke(instance, list);
assertEquals(res, List.of(6, 7, 8)); assertEquals(res, List.of(6, 7, 8));
} }
@Test
public void testBug328() throws Exception {
var loader = new ByteArrayClassLoader();
loader.loadClass(TestCodegen.path.resolve("Bug328B.class"));
var classFiles = generateClassFiles(loader, "Bug328.jav");
var clazz = classFiles.get("Bug328");
var instance = clazz.getDeclaredConstructor().newInstance();
}
} }