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

This commit is contained in:
Daniel Holle 2024-04-08 13:18:27 +02:00
parent 46a7f61234
commit da74898f9d
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,8 @@
public class Bug312 {
Bug312A i = new Bug312A();
public main() {
if (i == null) {}
}
}
class Bug312A {}

View File

@ -281,9 +281,12 @@ public class Codegen {
return TargetType.Float;
} else if (left.equals(TargetType.Long) || right.equals(TargetType.Long)) {
return TargetType.Long;
} else {
} else if (left.equals(TargetType.Integer) || right.equals(TargetType.Integer)) {
return TargetType.Integer;
} else if (left.equals(TargetType.Short) || right.equals(TargetType.Short)) {
return TargetType.Short;
}
return left;
}
private void generateBinaryOp(State state, TargetBinaryOp op) {

View File

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