Whole file
terryyin/lizard
The author described this change as “fix(java): enhance parsing of generic and qualified type names in anonymous classes”. It counts as a record because the checks below fail on the code as it stood at 74c244b9c and pass on 0b97a9ae8, with nothing else changed between the two runs.
Projectterryyin/lizard
Fix saved2026-06-15
Sharing licenceMIT · LICENSE.txt
Change size+6 −2
What the code was meant to do, written into the code itself as a save note
fix(java): enhance parsing of generic and qualified type names in anonymous classes
The change
| 192 | 192 | self.next(self._state_new_parameters) | |
| 193 | 193 | ||
| 194 | 194 | def _state_new_parameters(self, token): | |
| 195 | - | if self._new_generic_depth > 0 or token == "<": | |
| 195 | + | if self._new_generic_depth > 0 or token.startswith("<"): | |
| 196 | 196 | # Skip the instantiated type's generic arguments, e.g. the <Long> in | |
| 197 | - | # new ThreadLocal<Long>(), so they don't end the search for '(' / '{'. | |
| 197 | + | # new ThreadLocal<Long>() or the <? super T> wildcard token, so they | |
| 198 | + | # don't end the search for '(' / '{'. | |
| 198 | 199 | self._new_generic_depth += token.count("<") - token.count(">") | |
| 199 | 200 | return | |
| 200 | 201 | if token == "(": | |
| ⋯ | |||
| 204 | 205 | def callback(): | |
| 205 | 206 | self.next(self._state_global) | |
| 206 | 207 | self.sub_state(JavaClassBodyStates("(anonymous)", False, self.context), callback, token) | |
| 208 | + | return | |
| 209 | + | if token == "." or token[0].isalpha() or token[0] == '_': | |
| 210 | + | # Unqualified or qualified type name segment before '(' / '{'. | |
| 207 | 211 | return | |
| 208 | 212 | self.next(self._state_global, token) | |
| 209 | 213 | ||
The check that tells the two apart
fail→pass·test/test_languages/testJava.py::TestJava::test_qualified_type_anonymous_class
fail→pass·test/test_languages/testJava.py::TestJava::test_wildcard_generic_anonymous_class
Check file test/test_languages/testJava.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it74c244b9cef455f344a1aa2025e7bc89356bf5c1
Broken version dated2026-06-15
Modulelizard_languages.java
Units changedJavaStates
Fingerprint74373fd0712969f7
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in terryyin/lizard
- 2026-08-08fix(java): do not report control structures as methods
- 2026-07-02HalsteadClassifier
- 2026-07-02fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields
- 2026-06-15fix(golike): register generic functions with [...] type params
- 2026-06-11fix(script): stop a '#' comment continuing past a trailing backslash (#317)
- 2026-06-02fix(objc): handle nested parens in block / function-pointer param types