There is a couple of minor issues with the AST model for var types:
a) the JCVariableDecl.vartype is filled in for implicit lambda parameters and for-each variables, but not for ordinary local vars (like var i = 0;). This is inconsistent and can cause a real problem if Attr.postAttr is invoked, as it will add a JCErroneous for the missing vartype
b) the SourcePosition.getStartPosition for a local var (without modifiers) points to the variable name, while it would be more consistent to point to the beginning of "var"
There is also a minor issue in jshell:
---
jshell> var x = () -> {};
| Error:
| incompatible types: java.lang.Object is not a functional interface
| var x = () -> {};
| ^------^
---
And analogous error in javac:
---
$ javac T.java
T.java:3: error: cannot infer type for local variable broken
var broken = () -> {};
^
(lambda expression needs an explicit target-type)
1 error
---
a) the JCVariableDecl.vartype is filled in for implicit lambda parameters and for-each variables, but not for ordinary local vars (like var i = 0;). This is inconsistent and can cause a real problem if Attr.postAttr is invoked, as it will add a JCErroneous for the missing vartype
b) the SourcePosition.getStartPosition for a local var (without modifiers) points to the variable name, while it would be more consistent to point to the beginning of "var"
There is also a minor issue in jshell:
---
jshell> var x = () -> {};
| Error:
| incompatible types: java.lang.Object is not a functional interface
| var x = () -> {};
| ^------^
---
And analogous error in javac:
---
$ javac T.java
T.java:3: error: cannot infer type for local variable broken
var broken = () -> {};
^
(lambda expression needs an explicit target-type)
1 error
---