-
Notifications
You must be signed in to change notification settings - Fork 14
reduce duplication of FunctionN as scala.runtime.java8.JFunction #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The The difficulty is with specialization. import scala.*;
import java.util.Arrays;
public class Test {
private static void printApplyMethods() {
Arrays.stream(Thread.currentThread().getStackTrace()).filter(x -> x.getMethodName().startsWith("apply")).forEach(System.out::println);
System.out.println();
}
public static void main(String[] args) {
Function0<String> f0_String = () -> "";
f0_String.apply();
Function0<? extends Object> f0_Object = f0_String;
f0_Object.apply();
Function0$mcI$sp f0_int = () -> {printApplyMethods(); return 42;};
f0_int.apply();
f0_int.apply$mcI$sp(); // Routes through boxing in `scala.Function0.apply$mcI$sp`
Function0<Integer> f0_Integer = (Function0<Integer>) (Object) f0_int;
f0_Integer.apply();
Function1<String, String> f1_String_String = x -> x;
f1_String_String.apply("");
Function1$mcII$sp f1_int_int = x -> {printApplyMethods(); return 42;};
f1_int_int.apply$mcII$sp(0); // Routes through boxing in `scala.Function1.apply$mcII$sp`
Function1<Integer, Integer> f1_Integer_Integer = (Function1<Integer, Integer>) (Object) f1_int_int;
f1_Integer_Integer.apply(42);
}
}
An easy first step would be to change non-specialized lambdas to directly use |
Related: #36 |
Right you are. I misinterpreted the crash. |
This is largely fixed in scala/scala#4971. I'm going to close this and open a followup (low priority) ticket for specialized |
We'll still need something for void-return functions. First stab: scala/scala@0db3f41
The text was updated successfully, but these errors were encountered: