Surprised that TYPE_USE annotations are accepted on `var` lambda parameters
Dan Smith
daniel.smith at oracle.com
Fri Oct 21 19:47:19 UTC 2022
On Oct 11, 2022, at 12:17 PM, Chris Povirk <cpovirk at google.com<mailto:cpovirk at google.com>> wrote:
I didn't find a clear statement either way in my browsing of the JLS. On the one hand, JLS 9.7.4 specifically forbids using type-use annotations with var only for local variables:
"If the annotation appears before a void method declaration or a local variable declaration that uses var (§14.4), then there is no closest type."
On the other hand, I don't think any of the JLS rules for finding the "closest type" would apply in the case of a var lambda parameter.
Thanks for noticing this, I've filed a bug to fix the spec:
https://bugs.openjdk.org/browse/JDK-8295807
I've CC'ed Srikanth who can pursue a bug fix for javac.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20221021/12a88b16/attachment-0001.htm>
More information about the compiler-dev
mailing list