new inference: lambda functional type detection

This commit is contained in:
Anna Kozlova
2014-02-19 18:25:39 +01:00
parent 3093e7e63f
commit 2a16fd1641
4 changed files with 86 additions and 56 deletions

View File

@@ -0,0 +1,26 @@
import java.util.Optional;
import java.util.function.Function;
import static java.util.Optional.of;
class MatchTest {
{
Match<String, Integer> match = match((String s) -> s.equals("1") ? of(1) : null, s -> 1);
}
private <M>Optional<M> bar() {
return null;
}
public static <T1, V1, W1> Match<T1, V1> match(Extractor<T1, W1> e, Function<W1, V1> c) {
return null;
}
class Match<T, V> {}
interface Extractor<T, W> {
Optional<W> unapply(T t);
}
}