lambda-> method ref: do not insert type args to reference type if they were inferred for lambda expression

This commit is contained in:
Anna Kozlova
2014-04-11 12:35:01 +02:00
parent 86e8dd82fd
commit a3348c56cb
6 changed files with 135 additions and 15 deletions

View File

@@ -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());
}
}

View File

@@ -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){}
}

View File

@@ -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());
}
}

View File

@@ -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){}
}