mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
[java] parses local-var syntax for lambda parameters (IDEA-187804)
This commit is contained in:
+7
-5
@@ -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) { }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.function.Function;
|
||||
|
||||
class C {
|
||||
void m() {
|
||||
Function<String, String> f = (var var) -> var;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user