forked from JavaTX/JavaCompilerCore
Let lambda functions use Object instead of generic parameters
This commit is contained in:
parent
374d2e811b
commit
1ad4cfcb21
@ -705,11 +705,15 @@ public class Codegen {
|
|||||||
} else {
|
} else {
|
||||||
var name = "lambda$" + lambdaCounter++;
|
var name = "lambda$" + lambdaCounter++;
|
||||||
var parameters = new ArrayList<>(lambda.captures());
|
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(
|
impl = new TargetMethod(
|
||||||
0, name, Set.of(), Set.of(),
|
0, name, Set.of(), Set.of(),
|
||||||
parameters, lambda.returnType(), lambda.block()
|
parameters,
|
||||||
|
lambda.returnType() instanceof TargetGenericType ? TargetType.Object : lambda.returnType(),
|
||||||
|
lambda.block()
|
||||||
);
|
);
|
||||||
generateMethod(impl);
|
generateMethod(impl);
|
||||||
lambdas.put(lambda, impl);
|
lambdas.put(lambda, impl);
|
||||||
@ -736,7 +740,9 @@ public class Codegen {
|
|||||||
|
|
||||||
var params = new ArrayList<TargetType>();
|
var params = new ArrayList<TargetType>();
|
||||||
params.add(new TargetRefType(clazz.qualifiedName()));
|
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));
|
var descriptor = TargetMethod.getDescriptor(lambda.type(), params.toArray(TargetType[]::new));
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user