JLS Technical Amguity
Sam Hooper
samhooper256 at gmail.com
Fri Jun 19 00:38:34 UTC 2020
Hi,
There appears to be a technical ambiguity in the JLS 14. The restricted
identifier yield is allowed as the name of a type variable when, according
to the specification, it should not be. The following compiles fine:
class Outer<yield>{
class Inner<yield>{
<yield> void method() {}
}
}
which it should not according to the following productions from JLS 14:
TypeParameters:
< TypeParameterList
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-8.html#jls-TypeParameterList>
>
TypeParameterList:
TypeParameter
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-TypeParameter>
{, TypeParameter
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-TypeParameter>
}
TypeParameter:
{TypeParameterModifier
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-TypeParameterModifier>
} TypeIdentifier
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-3.html#jls-TypeIdentifier>
[TypeBound
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-4.html#jls-TypeBound>
]
TypeIdentifier:
Identifier
<https://docs.oracle.com/javase/specs/jls/se14/html/jls-3.html#jls-Identifier>
but not var or yield
Thanks for your time.
-Sam Hooper
More information about the jls-jvms-spec-comments
mailing list