2017-09-26 11:52:53 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
2017-11-24 16:14:33 +00:00
|
|
|
* @bug 8177466 8191834
|
2017-09-26 11:52:53 +00:00
|
|
|
* @summary Add compiler support for local variable type-inference
|
|
|
|
* @compile/fail/ref=BadLocalVarInferenceTest.out -XDrawDiagnostics BadLocalVarInferenceTest.java
|
|
|
|
*/
|
|
|
|
|
|
|
|
class BadLocalVarInferenceTest {
|
|
|
|
|
|
|
|
interface Foo<X> {
|
|
|
|
void m(X x);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Supplier<X> {
|
|
|
|
void m(X x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
var x;
|
|
|
|
var f = () -> { };
|
|
|
|
var m = this::l;
|
|
|
|
var g = null;
|
|
|
|
var d = d = 1;
|
|
|
|
var k = { 1 , 2 };
|
|
|
|
var l = new Foo<>() { //LHS was Foo<String>
|
|
|
|
@Override
|
|
|
|
void m(String s) { }
|
|
|
|
};
|
|
|
|
var s = f(x -> { x.charAt(0); }); //LHS was String
|
2017-11-24 16:14:33 +00:00
|
|
|
var t = m(); //void
|
2017-09-26 11:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
<Z> Z f(Supplier<Z> sz) { return null; }
|
2017-11-24 16:14:33 +00:00
|
|
|
|
|
|
|
void m() { }
|
2017-09-26 11:52:53 +00:00
|
|
|
}
|