Source:
public Optional<MethodHandleAndConstructor> specialize(Signature boundSignature, BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { for (Map.Entry<String, Class<?>> entry : specializedTypeParameters.entrySet()) { if (!entry.getValue().isAssignableFrom(boundVariables.getTypeVariable(entry.getKey()).getJavaType())) { return Optional.empty(); } } Class<?> returnContainerType = getNullAwareReturnType(typeManager.getType(boundSignature.getReturnType()).getJavaType(), nullable); if (!returnContainerType.equals(methodHandle.type().returnType())) { return Optional.empty(); } for (int i = 0; i < boundSignature.getArgumentTypes().size(); i++) { if (boundSignature.getArgumentTypes().get(i).getBase().equals("function")) { if (!lambdaInterface.containsKey(i) || !lambdaInterface.get(i).isAnnotationPresent(FunctionalInterface.class)) { return Optional.empty(); } } else { Class<?> argumentType = typeManager.getType(boundSignature.getArgumentTypes().get(i)).getJavaType(); boolean nullableParameter = isParameterNullable(argumentType, nullableArguments.get(i), nullFlags.get(i)); Class<?> argumentContainerType = getNullAwareContainerType(argumentType, nullableParameter); if (!argumentNativeContainerTypes.get(i).isAssignableFrom(argumentContainerType)) { return Optional.empty(); } } } MethodHandle methodHandle = this.methodHandle; for (ImplementationDependency dependency : dependencies) { methodHandle = MethodHandles.insertArguments(methodHandle, 0, dependency.resolve(boundVariables, typeManager, functionRegistry)); } MethodHandle constructor = null; if (this.constructor.isPresent()) { constructor = this.constructor.get(); for (ImplementationDependency dependency : constructorDependencies) { constructor = MethodHandles.insertArguments(constructor, 0, dependency.resolve(boundVariables, typeManager, functionRegistry)); } } return Optional.of(new MethodHandleAndConstructor(methodHandle, Optional.ofNullable(constructor))); }

Target:
public Optional<MethodHandleAndConstructor> specialize(Signature boundSignature, BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { for (Map.Entry<String, Class<?>> entry : specializedTypeParameters.entrySet()) { if (!entry.getValue().isAssignableFrom(boundVariables.getTypeVariable(entry.getKey()).getJavaType())) { return Optional.empty(); } } Class<?> returnContainerType = getNullAwareReturnType(typeManager.getType(boundSignature.getReturnType()).getJavaType(), nullable); if (!returnContainerType.equals(methodHandle.type().returnType())) { return Optional.empty(); } for (int i = 0; i < boundSignature.getArgumentTypes().size(); i++) { if (boundSignature.getArgumentTypes().get(i).getBase().equals(FunctionType.NAME)) { if (!lambdaInterface.get(i).isPresent()) { return Optional.empty(); } } else { Class<?> argumentType = typeManager.getType(boundSignature.getArgumentTypes().get(i)).getJavaType(); boolean nullableParameter = isParameterNullable(argumentType, nullableArguments.get(i), nullFlags.get(i)); Class<?> argumentContainerType = getNullAwareContainerType(argumentType, nullableParameter); if (!argumentNativeContainerTypes.get(i).isAssignableFrom(argumentContainerType)) { return Optional.empty(); } } } MethodHandle methodHandle = this.methodHandle; for (ImplementationDependency dependency : dependencies) { methodHandle = MethodHandles.insertArguments(methodHandle, 0, dependency.resolve(boundVariables, typeManager, functionRegistry)); } MethodHandle constructor = null; if (this.constructor.isPresent()) { constructor = this.constructor.get(); for (ImplementationDependency dependency : constructorDependencies) { constructor = MethodHandles.insertArguments(constructor, 0, dependency.resolve(boundVariables, typeManager, functionRegistry)); } } return Optional.of(new MethodHandleAndConstructor(methodHandle, Optional.ofNullable(constructor))); }