J2K: Fix type parameters in LHS of callable reference

This commit is contained in:
Simon Ogorodnik
2020-07-17 17:22:39 +03:00
parent 96d0b1c47a
commit 468af0bb85
8 changed files with 69 additions and 7 deletions
@@ -0,0 +1,21 @@
// RUNTIME_WITH_FULL_JDK
import java.util.List;
public class TestLambda<T> {
public static class Box<Q> {
private Q value;
public Q unbox() {
return value;
}
public Box(Q q) {
value = q;
}
}
public String toStringAllBox(List<Box<T>> list) {
return list.stream().map(Box<T>::unbox).map(T::toString).reduce((s1,s2) -> s1 + ", " + s2 ).orElse("");
}
}
@@ -0,0 +1,12 @@
class TestLambda<T> {
class Box<Q>(private val value: Q) {
fun unbox(): Q {
return value
}
}
fun toStringAllBox(list: List<Box<T>>): String {
return list.stream().map { obj: Box<T> -> obj.unbox() }.map { obj: T -> obj.toString() }
.reduce { s1: String, s2: String -> "$s1, $s2" }.orElse("")
}
}