[java] parses local-var syntax for lambda parameters (IDEA-187804)

This commit is contained in:
Roman Shevchenko
2018-03-08 18:14:26 +01:00
parent 8c5ebc6aca
commit 156b436799
8 changed files with 83 additions and 22 deletions
@@ -1,11 +1,12 @@
import java.util.function.Function;
class Main {
private static void localVariableDeclaration() {
var a = 1;
<error descr="'var' is not allowed in a compound declaration">var b = 2</error>, <error descr="'var' is not allowed in a compound declaration">c = 3.0;</error>
<error descr="'var' is not allowed as an element type of an array">var</error> d[] = new int[4];
var d1 = new int[] {4};
var d2 = new int[4];
var d1 = new int[] {4};
var d2 = new int[4];
<error descr="Cannot infer type: 'var' on variable without initializer">var</error> e;
var f = <error descr="Array initializer is not allowed here">{ 6 }</error>;
var g = (<error descr="Incompatible types. Found: 'int', required: 'null'">g = 7</error>);
@@ -30,9 +31,11 @@ class Main {
<error descr="Cannot infer type: method reference requires an explicit target type">var</error> m = Main::localVariableDeclaration;
<error descr="Cannot infer type: variable initializer is 'null'">var</error> g = null;
var runnable = true ? <error descr="Lambda expression not expected here">() -> {}</error> : <error descr="Lambda expression not expected here">() -> {}</error>;
Function<String, String> f1 = (<error descr="Cannot resolve symbol 'var'">var</error> var) -> var;
}
private void forEachType(String[] strs, Iterable<String> it, Iterable raw) {
private void forEachType(String[] strs, Iterable<String> it, Iterable raw) {
for (var str : strs) {
String s = str;
}
@@ -56,6 +59,5 @@ class Main {
private void tryWithResources(AutoCloseable c) throws Exception {
try (<error descr="Cannot infer type: variable initializer is 'null'">var</error> v = null) { }
try (var v = c; var v1 = c) { }
}
}
}
@@ -0,0 +1,7 @@
import java.util.function.Function;
class C {
void m() {
Function<String, String> f = (var var) -> var;
}
}