introduce functional parameter: do not fold as functional interface creation would be in the place where local vars are not available

This commit is contained in:
Anna Kozlova
2015-01-15 10:25:52 +01:00
parent 55e83bf6e5
commit 574577fe73
4 changed files with 56 additions and 0 deletions
@@ -0,0 +1,27 @@
import java.util.function.Function;
class Test {
{
final int[] equals = new int[0];
performTest(new Function<String[],String[]>() {
public String[] apply(String[] fields) {
System.out.println();
return getIndexed(fields, equals);
}
});
}
private static void performTest(Function<String[], String[]> anObject) {
String[] fields = new String[0];
final String[] indexed = anObject.apply(fields);
System.out.println(indexed);
}
private static String[] getIndexed(String[] fields, int[] indices) {
return new String[indices.length];
}
}
@@ -0,0 +1,20 @@
class Test {
{
performTest(new int[0]);
}
private static void performTest(int[] equals) {
String[] fields = new String[0];
<selection>System.out.println();
final String[] indexed = getIndexed(fields, equals);</selection>
System.out.println(indexed);
}
private static String[] getIndexed(String[] fields, int[] indices) {
return new String[indices.length];
}
}