fix(tpv-class): lookup_field_by_class 识别 16hex 类键前缀为 sha1,修复 GSList[Param] 模块解析误报

This commit is contained in:
TermiNexus committed 2026-09-09 08:57:29 +08:00
1 parent 82558bd86b
commit 3e4f3b88b0
1 file changed
+28 -1
+28 -1
View File
@@ -897,7 +897,34 @@ class StructGenMixin:
string.strncpy(mod_buf_q, class_name, mod_len_q)
mod_buf_q[mod_len_q] = '\0'
if string.strcmp(mod_buf_q, "t") != 0 and string.strcmp(mod_buf_q, "c") != 0:
mod_sha1_q: str = self._resolve_module_sha1(mod_buf_q, from_imports)
# 模块段是 16 位 hex = SHA1 字面量("{16hex}.Class" 类键形态,
# 泛型类型实参 _norm_type_arg_name 规范化产物,如
# "29fdb5e25dc949f4.Param"——GSList[Param] 特化方法体内
# `cur: T | t.CPtr = self.Head` 经 resolve_generic_type_name
# 替换 T 为实参串后 AnnotClassName 即该形态):模块段即模块
# SHA1,类已注册就证明该模块已编译,直接按 name+sha1 精确匹配,
# 不走 _resolve_module_sha1(store 键是模块名不是 sha1,查
# "29fdb5e25dc949f4" 恒 None → L956 fail-fast 误杀。本应找得到)。
# 对齐 find_struct L571-592 同款 hex 处理与 TypeGenResolve
# _is_sha1_prefixed 语义(含 sha1 前缀名的 Name/Attribute 注解
# 解析均跳过 import 检查)。泛型下标内点(GSList[sha.Param])
# 已被 _last_dot_outside_brackets 跳过,此处仅顶层 a.b 形态。
mod_hex_ok_q: int = 1
if string.strlen(mod_buf_q) == 16:
for hi_q in range(16):
ch_hq: t.CChar = mod_buf_q[hi_q]
if not ((ch_hq >= 48 and ch_hq <= 57) or (ch_hq >= 97 and ch_hq <= 102)):
mod_hex_ok_q = 0
break
else:
mod_hex_ok_q = 0
mod_sha1_q: str = None
if mod_hex_ok_q != 0:
# SHA1 前缀自身即"已登记"证据(与既有解析同语义):
# mod_sha1_q 别名 mod_buf_q(下方各返回路径统一 free 一次)
mod_sha1_q = mod_buf_q
else:
mod_sha1_q = self._resolve_module_sha1(mod_buf_q, from_imports)
if mod_sha1_q is not None:
mod_entry_q: GenTypes.StructEntry | t.CPtr = \
self.find_struct_by_module(bare_q, mod_sha1_q)