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.

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

192192 self.next(self._state_new_parameters)
193193
194194 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("<"):
196196 # 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 '(' / '{'.
198199 self._new_generic_depth += token.count("<") - token.count(">")
199200 return
200201 if token == "(":
204205 def callback():
205206 self.next(self._state_global)
206207 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 '(' / '{'.
207211 return
208212 self.next(self._state_global, token)
209213

The check that tells the two apart

failpass·test/test_languages/testJava.py::TestJava::test_qualified_type_anonymous_class
failpass·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