Änderung sodass OLFun2 nun den Rückgabetyp des Funktionstyps auch zurückgibt.

Anpassung entsprechend in den Tests.
This commit is contained in:
Etienne Zink 2022-04-20 15:20:01 +02:00
parent a0367d5464
commit 1cf1c99e72
4 changed files with 5 additions and 3 deletions

View File

@ -592,7 +592,6 @@ public class BytecodeGenMethod implements StatementVisitor {
this.lamCounter++; this.lamCounter++;
String typeErasure = createDescriptorWithTypeErasure(lambdaExpression); String typeErasure = createDescriptorWithTypeErasure(lambdaExpression);
//ToDo Etienne: Double Check
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(lambdaExpression.getReturnType()); RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(lambdaExpression.getReturnType());
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = lambdaExpression List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = lambdaExpression
.params .params
@ -828,7 +827,6 @@ public class BytecodeGenMethod implements StatementVisitor {
} else if(!helper.isInCurrPkg(clazz)){ } else if(!helper.isInCurrPkg(clazz)){
if(clazz.contains(CONSTANTS.$$)) { if(clazz.contains(CONSTANTS.$$)) {
mDesc = helper.getDescriptorOfApplyMethod(methCallType); mDesc = helper.getDescriptorOfApplyMethod(methCallType);
//ToDo Etienne: Double Check
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType()); RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType());
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall
.arglist .arglist

View File

@ -153,7 +153,6 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
return desc; return desc;
} }
//ToDo Etienne: ändern
@Override @Override
public String visit(Lambda lambdaExpression) { public String visit(Lambda lambdaExpression) {
String desc = "("; String desc = "(";

View File

@ -47,24 +47,28 @@ public class OLFun2Test {
@Test @Test
public void mExistsWithIntegerInteger() throws Exception{ public void mExistsWithIntegerInteger() throws Exception{
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt); Method m = classToTest.getDeclaredMethod("m", classFun1IntInt);
assertEquals(Integer.class, m.getReturnType());
assertNotNull(m); assertNotNull(m);
} }
@Test @Test
public void mExistsWithIntegerDouble() throws Exception{ public void mExistsWithIntegerDouble() throws Exception{
Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble); Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble);
assertEquals(Double.class, m.getReturnType());
assertNotNull(m); assertNotNull(m);
} }
@Test @Test
public void mExistsWithDoubleInteger() throws Exception{ public void mExistsWithDoubleInteger() throws Exception{
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt); Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt);
assertEquals(Integer.class, m.getReturnType());
assertNotNull(m); assertNotNull(m);
} }
@Test @Test
public void mExistsWithDoubleDouble() throws Exception{ public void mExistsWithDoubleDouble() throws Exception{
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble); Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble);
assertEquals(Double.class, m.getReturnType());
assertNotNull(m); assertNotNull(m);
} }

View File

@ -9,5 +9,6 @@ public class OLFun2 {
m(f){ m(f){
var x = 1; var x = 1;
var y = f.apply(x + x) + 1; var y = f.apply(x + x) + 1;
return y;
} }
} }