Fix wrong type conversion, see #297
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m51s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m51s
This commit is contained in:
parent
01e374eadd
commit
c07d4d36e9
11
resources/bytecode/javFiles/Bug297.jav
Normal file
11
resources/bytecode/javFiles/Bug297.jav
Normal file
@ -0,0 +1,11 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Bug297 {
|
||||
public static operation(func, a, b) {
|
||||
return func.apply(a, b);
|
||||
}
|
||||
|
||||
public exec() {
|
||||
return Foo.operation((x, y) -> x + y, 10, 10);
|
||||
}
|
||||
}
|
@ -966,8 +966,8 @@ public class Codegen {
|
||||
state.contextType = state.returnType;
|
||||
generate(state, ret.expression());
|
||||
state.contextType = ctype;
|
||||
boxPrimitive(state, ret.expression().type());
|
||||
convertTo(state, ret.expression().type(), state.returnType);
|
||||
boxPrimitive(state, state.returnType);
|
||||
mv.visitInsn(ARETURN);
|
||||
} else
|
||||
mv.visitInsn(RETURN);
|
||||
|
@ -947,4 +947,12 @@ public class TestComplete {
|
||||
var clazz = classFiles.get("Bug296");
|
||||
clazz.getDeclaredMethod("m1").invoke(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug297() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug297.jav");
|
||||
var clazz = classFiles.get("Bug297");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
clazz.getDeclaredMethod("exec").invoke(instance);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user