mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 05:09:37 +07:00
lambda-> method ref: do not insert type args to reference type if they were inferred for lambda expression
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Box<T>
|
||||
{
|
||||
public Box(T value)
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
private final T _value;
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
{
|
||||
List<Box<String>> l1 = new ArrayList<>();
|
||||
l1.add(new Box<>("Foo"));
|
||||
l1.add(new Box<>("Bar"));
|
||||
|
||||
List<String> l3 = l1.stream()
|
||||
.map(Box::getValue)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Box<T>
|
||||
{
|
||||
public Box(T value)
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
private final T _value;
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
{
|
||||
foo(Box<String>::getValue);
|
||||
}
|
||||
|
||||
<K> void foo(Function<Box<K>, K> f){}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Box<T>
|
||||
{
|
||||
public Box(T value)
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
private final T _value;
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
{
|
||||
List<Box<String>> l1 = new ArrayList<>();
|
||||
l1.add(new Box<>("Foo"));
|
||||
l1.add(new Box<>("Bar"));
|
||||
|
||||
List<String> l3 = l1.stream()
|
||||
.map((t) -> t.get<caret>Value())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// "Replace lambda with method reference" "true"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Box<T>
|
||||
{
|
||||
public Box(T value)
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
private final T _value;
|
||||
|
||||
public T getValue()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
{
|
||||
foo((Box<String> t) -> t.get<caret>Value());
|
||||
}
|
||||
|
||||
<K> void foo(Function<Box<K>, K> f){}
|
||||
}
|
||||
Reference in New Issue
Block a user