java 8 initial graph inference: allow to infer type information from siblings and parent calls

This commit is contained in:
anna
2013-02-08 11:34:25 +01:00
parent 0ac39239b2
commit a9c4a9c5ab
11 changed files with 226 additions and 9 deletions
@@ -0,0 +1,26 @@
import java.util.*;
class Main {
void foo(List<Integer> list) {
bar(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
bar1(list, i -> i.intValue(), i -> i.<error descr="Cannot resolve method 'unknown()'">unknown</error>());
}
<U, S_IN, S_OUT, R> R bar(List<S_IN> list,
Fun<S_IN, S_OUT> f1,
Fun<S_OUT, R> f2) {
return null;
}
<R, S_IN, S_OUT> R bar1(List<S_IN> list,
Fun<S_IN, S_OUT> f1,
Fun<S_OUT, R> f2) {
return null;
}
public interface Fun<T, R> {
public R _(T t);
}
}
@@ -0,0 +1,14 @@
class Main {
<R> void bar(Fun<Integer, R> collector) { }
<T, D> Fun<T, Integer> foo(D d) { return null; }
public void test() {
bar(foo(""));
}
interface Fun<T, R> {
R _(T t);
}
}
@@ -0,0 +1,24 @@
import java.util.*;
class Main {
void test(List<Integer> li) {
Fun<Stream<Integer>, Stream<Integer>> f = s -> s.substr(0);
foo(li, f, Collections.emptyList());
foo(li, s -> s.substr(0), Collections.emptyList());
}
<T, U, S_OUT extends Stream<U>, It extends Iterable<U>> Collection<U>
foo(Collection<T> coll, Fun<Stream<T>, S_OUT> f, It it) {
return null;
}
interface Stream<T> {
Stream<T> substr(long startingOffset);
}
interface Fun<T, R> {
R _(T t);
}
}
@@ -0,0 +1,15 @@
import java.util.*;
public class Main {
public static <T> T foo() {return null;}
public static <B> List<B> bar(B b) {return null;}
static {
List<String> s = bar(foo());
}
public static <B> B bar1(B b) {return null;}
static {
String s1 = bar1(foo());
}
}
@@ -0,0 +1,9 @@
class Main {
static <T> T foo(T t) { return null; }
static {
long l1 = foo(foo(1));
Integer i = 1;
long l2 = foo(foo(i));
}
}
@@ -0,0 +1,27 @@
import java.util.*;
class Main {
<T, R> Collector<T, R> m(Supplier<? extends R> supplier, BiConsumer<R, T> accumulator) {
return null;
}
<T, C extends Collection<T>> Collector<T, C> test1(Supplier<C> collectionFactory) {
return m(collectionFactory, Collection::add);
}
Collector<String, StringBuilder> test2(Supplier<StringBuilder> sb) {
return m(sb, StringBuilder::append);
}
interface Supplier<T> {
public T get();
}
interface Collector<T, R> {
}
interface BiConsumer<T, U> {
void accept(T t, U u);
}
}