diff --git a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java index d9b41787..7403f2e1 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java @@ -705,11 +705,15 @@ public class Codegen { } else { var name = "lambda$" + lambdaCounter++; var parameters = new ArrayList<>(lambda.captures()); - parameters.addAll(lambda.params()); + parameters.addAll(lambda.params().stream() + .map(param -> param.type() instanceof TargetGenericType ? new MethodParameter(TargetType.Object, param.name()) : param) + .toList()); impl = new TargetMethod( 0, name, Set.of(), Set.of(), - parameters, lambda.returnType(), lambda.block() + parameters, + lambda.returnType() instanceof TargetGenericType ? TargetType.Object : lambda.returnType(), + lambda.block() ); generateMethod(impl); lambdas.put(lambda, impl); @@ -736,7 +740,9 @@ public class Codegen { var params = new ArrayList(); params.add(new TargetRefType(clazz.qualifiedName())); - params.addAll(lambda.captures().stream().map(MethodParameter::type).toList()); + params.addAll(lambda.captures().stream() + .map(MethodParameter::type) + .toList()); var descriptor = TargetMethod.getDescriptor(lambda.type(), params.toArray(TargetType[]::new)); mv.visitVarInsn(ALOAD, 0);