lambda -> method reference: ensure functional type was not changed after transformation (IDEA-136163)

This commit is contained in:
Anna Kozlova
2015-02-17 12:57:22 +01:00
parent 6482dfe733
commit bcbc25e1de
3 changed files with 41 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
// "Replace lambda with method reference" "true"
import java.util.prefs.Preferences;
class Test {
private Preferences preferences;
{
foo(short.class, (Writer<Short>) Preferences::putInt);
}
private <T> void foo(Class<T> type, Writer<T> writer) {}
interface Writer<T> {
void write(Preferences preferences, String key, T value);
}
}

View File

@@ -0,0 +1,17 @@
// "Replace lambda with method reference" "true"
import java.util.prefs.Preferences;
class Test {
private Preferences preferences;
{
foo(short.class, (p, k, v) -> p.put<caret>Int(k, v));
}
private <T> void foo(Class<T> type, Writer<T> writer) {}
interface Writer<T> {
void write(Preferences preferences, String key, T value);
}
}