anonymous -> method ref: collapse receiver method references to raw receiver (IDEA-153261)

This commit is contained in:
Anna.Kozlova
2016-03-18 19:50:21 +01:00
parent 6daac099e6
commit 81a6342d17
6 changed files with 36 additions and 8 deletions

View File

@@ -0,0 +1,9 @@
// "Replace with method reference" "true"
import java.util.List;
import java.util.function.Function;
class MyTest {
Function<List<?>, String> TO_TEXT = Object::toString;
}

View File

@@ -0,0 +1,14 @@
// "Replace with method reference" "true"
import java.util.List;
import java.util.function.Function;
class MyTest {
Function<List<?>, String> TO_TEXT = new Func<caret>tion<List<?>, String>() {
@Override
public String apply(List<?> lst) {
return lst.toString();
}
};
}

View File

@@ -16,7 +16,7 @@ class Box<T>
}
{
foo(Box<String>::getValue);
foo((Function<Box<String>, String>) Box::getValue);
}
<K> void foo(Function<Box<K>, K> f){}

View File

@@ -5,6 +5,6 @@ import java.util.List;
class Sample {
List<Exception> foo = new ArrayList<>();
{
foo.forEach(Exception::printStackTrace);
foo.forEach(Throwable::printStackTrace);
}
}