lambda: replace raw inference from lambda with Object when it doesn't matter (IDEA-101788)

This commit is contained in:
anna
2013-02-25 14:12:42 +01:00
parent 8d651e0f86
commit a684c033a1
3 changed files with 79 additions and 4 deletions
@@ -0,0 +1,30 @@
public class CyclicReferenceTest {
void test(Match<String, Integer> match) {
Match<String, Integer> matcher = match.or(s -> Optional.empty(), i -> 2);
Match<String, Integer> matcher1 = match.or(s -> s.startsWith("_") ? Optional.of(1) : Optional.empty(), i -> 2);
}
}
class Match<T, V> {
public <W> Match<T, V> or(Extractor<T, W> e, Function<W, V> c) {
return this;
}
}
interface Extractor<T, W> {
Optional<W> unapply(T t);
}
interface Function<W, V> {
public V apply(W t);
}
class Optional<W> {
public static <T> Optional<T> empty() {
return null;
}
public static <T> Optional<T> of(T value) {
return null;
}
}