[lvti] Possible compiler bug
Tagir Valeev
amaembo at gmail.com
Sun Jun 25 10:36:06 UTC 2017
Hello! The following code is not compilable in [lvti] branch, but it should
be, to my opinion:
public class LvtiBug {
int x() { return 0; }
void test() {
var x = x();
}
}
$ javac LvtiBug.java
LvtiBug.java:5: error: cannot infer type for local variable x
var x = x();
^
(cannot use 'val' on self-referencing variable)
1 error
Also, I believe, the message should have 'var', not 'val':
diff -r a7aba322684f
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
---
a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
Fri
Jun 23 11:47:57 2017 +0100
+++
b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
Sun
Jun 25 17:34:47 2017 +0700
@@ -1205,7 +1205,7 @@
variable initializer is ''null''
compiler.misc.local.missing.init=\
- cannot use ''val'' on variable without initializer
+ cannot use ''var'' on variable without initializer
compiler.misc.local.lambda.missing.target=\
lambda expression needs an explicit target-type
@@ -1217,7 +1217,7 @@
array initializer needs an explicit target-type
compiler.misc.local.self.ref=\
- cannot use ''val'' on self-referencing variable
+ cannot use ''var'' on self-referencing variable
compiler.misc.local.non.denotable=\
inferred type is non denotable
With best regards,
Tagir Valeev
More information about the amber-dev
mailing list