Fix #310
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m49s

This commit is contained in:
Daniel Holle 2024-04-08 11:52:52 +02:00
parent e59accf7ee
commit 46a7f61234
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,9 @@
import java.lang.Integer;
import java.lang.String;
public class Bug310 {
Integer i = 3;
public toString() {
return i.toString();
}
}

View File

@ -1029,8 +1029,10 @@ public class Codegen {
break;
}
case TargetMethodCall call: {
if (!call.isStatic())
if (!call.isStatic()) {
generate(state, call.expr());
boxPrimitive(state, call.expr().type());
}
for (var i = 0; i < call.args().size(); i++) {
var e = call.args().get(i);
var arg = call.parameterTypes().get(i);

View File

@ -1031,4 +1031,12 @@ public class TestComplete {
var instance = clazz.getDeclaredConstructor().newInstance();
clazz.getDeclaredMethod("main").invoke(instance);
}
@Test
public void testBug310() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug310.jav");
var clazz = classFiles.get("Bug310");
var instance = clazz.getDeclaredConstructor().newInstance();
assertEquals(clazz.getDeclaredMethod("toString").invoke(instance), "3");
}
}