lambda -> method refs: check if result method reference is valid

This commit is contained in:
Anna Kozlova
2014-11-11 15:21:35 +01:00
parent 01c823a6d8
commit 0506cb77bc
5 changed files with 115 additions and 132 deletions

View File

@@ -0,0 +1,13 @@
// "Replace lambda with method reference" "true"
class Example {
public void m() {
}
{
Runnable r = ex()::m;
}
Example ex() {
return this;
}
}

View File

@@ -0,0 +1,12 @@
// "Replace lambda with method reference" "false"
import java.io.PrintStream;
import java.util.function.BiConsumer;
class Test {
{
BiConsumer<PrintStream, String> printer = (printStream, x) -> get(printSt<caret>ream).println(x);
}
PrintStream get(PrintStream p) {return p;}
}

View File

@@ -0,0 +1,13 @@
// "Replace lambda with method reference" "true"
class Example {
public void m() {
}
{
Runnable r = () -> ex().<caret>m();
}
Example ex() {
return this;
}
}