mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 16:39:37 +07:00
[java-inspections] LambdaCanBeMethodReference: disable conversion in many cases when cast is required
Fixes IDEA-267865 Add a option for Java's method reference inspection that ignore lambda which can't convert into method reference without a cast GitOrigin-RevId: b6f762383d6ba1ef19a5de36e0ad53d107ba4e80
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9f3d7463a1
commit
bcb843dd8f
@@ -1,21 +0,0 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.*;
|
||||
class IDEA100385 {
|
||||
void foo(N<Double> n, List<Double> l){
|
||||
n.forEach((DoubleConsumer) l::add);
|
||||
}
|
||||
static interface N<E> {
|
||||
default void forEach(DoubleConsumer consumer) {
|
||||
}
|
||||
void forEach(Consumer<? super E> consumer);
|
||||
}
|
||||
|
||||
interface DoubleConsumer {
|
||||
void _(double d);
|
||||
}
|
||||
|
||||
interface Consumer<T> {
|
||||
public void accept(T t);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// "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);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.*;
|
||||
class IDEA100385 {
|
||||
void foo(N<Double> n, List<Double> l){
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
class Foo {}
|
||||
class Bar {}
|
||||
class Something {
|
||||
static void stuff(Function<Foo, Bar> foo2bar) {}
|
||||
static void stuff(Supplier<Bar> sup4Bar) {}
|
||||
}
|
||||
class Something2 {
|
||||
static Bar bar(Foo foo) { return null; }
|
||||
static Bar bar() { return null; }
|
||||
}
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
Something.stuff(foo -> <caret>Something2.bar(foo));
|
||||
Something.stuff(() -> Something2.bar());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
// "Replace lambda with method reference" "false"
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
class Test {
|
||||
|
||||
Reference in New Issue
Block a user