fix(overload): _PyiClass 补传内存池,修复 undefined name mb

类内方法的重载后缀要调用 GenApi.overload_sig_suffix(pool, ...),但 _PyiClass 之前没有内存池参数。追加可选参数 mb 并从 _GeneratePyiFromAst 的两个调用点(模块级类、嵌套类)传下去;未传时 _PyiOverloadSuffix 返回 None,非重载路径行为不变。
This commit is contained in:
TermiNexus committed 2026-10-24 19:46:54 +08:00
1 parent af445058b4
commit d2833f6e0c
1 file changed
+3 -3
+3 -3
View File
@@ -791,7 +791,7 @@ def _PyiFunction(buf: bytes, buf_size: sizet, pos: sizet, fn: ast.FunctionDef*,
# _PyiClass - emit a class definition (fields and method stubs).
def _PyiClass(buf: bytes, buf_size: sizet, pos: sizet, cls: ast.ClassDef*, indent_level: int) -> sizet:
def _PyiClass(buf: bytes, buf_size: sizet, pos: sizet, cls: ast.ClassDef*, indent_level: int, mb: memhub.MemBuddy* = None) -> sizet:
"""Emit a class definition into buf and return the new pos"""
# enum / struct / union / renum sugar: never write EnumBase / StructBase / ... bases.
cls_header: str = "class"
@@ -970,7 +970,7 @@ def _PyiClass(buf: bytes, buf_size: sizet, pos: sizet, cls: ast.ClassDef*, inden
# Nested classes
elif sk == ast.ASTKind.ClassDef:
ncls: ast.ClassDef* = ast.ClassDef*(stmt)
pos = _PyiClass(buf, buf_size, pos, ncls, indent_level + 1)
pos = _PyiClass(buf, buf_size, pos, ncls, indent_level + 1, mb)
has_member = 1
ci += 1
@@ -1125,7 +1125,7 @@ def _GeneratePyiFromAst(mb: memhub.MemBuddy*, tree: ast.AST*, rel_path: str, buf
# Class definition
elif k == ast.ASTKind.ClassDef:
cls: ast.ClassDef* = ast.ClassDef*(stmt)
pos = _PyiClass(buf, buf_size, pos, cls, 0)
pos = _PyiClass(buf, buf_size, pos, cls, 0, mb)
# Annotated variable declaration
elif k == ast.ASTKind.AnnAssign: