method refs: check cyclic inference for method refs

This commit is contained in:
anna
2012-10-04 13:24:25 +02:00
parent 96bf64f976
commit 120111d01b
5 changed files with 61 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
class MyTest<E> {
MyTest(E e) {
}
interface I<T> {
MyTest<T> _(T t);
}
static <Y> void bar(Y arg, I<Y> i) {
i._(arg);
}
static <Y> void bar(I<Y> i, Y arg) {
i._(arg);
}
static <Y> void bar(I<Y> i) {
i._(null);
}
public static void main(String[] args) {
I<String> i = MyTest::new;
bar("", MyTest<String>::new);
bar("", MyTest::new);
bar(MyTest<String>::new, "");
bar(MyTest::new, "");
bar(<error descr="Cyclic inference">MyTest::new</error>);
bar(<error descr="Cyclic inference">MyTest<String>::new</error>);
}
}