diff --git a/lib/core/Handles/HandlesExprCall.py b/lib/core/Handles/HandlesExprCall.py index 35e5022..892ff57 100644 --- a/lib/core/Handles/HandlesExprCall.py +++ b/lib/core/Handles/HandlesExprCall.py @@ -3921,6 +3921,22 @@ class ExprCallHandle(BaseHandle): adjusted = Gen._adjust_args(call_args_fb, func) result = Gen.builder.call(func, adjusted, name=f"call_{FullMethodName}") return result + if ClassName.startswith('list[') and ClassName in Gen.structs: + # 泛型特化方法未生成时,回退到裸模板 list 的同名方法 + struct_type = Gen.structs[ClassName] + self_ptr_type = ir.PointerType(struct_type) + BareFuncName: str = f'list.{MethodName}' + func = Gen._find_function(BareFuncName) + if func is not None: + if isinstance(ObjVal.type, ir.PointerType) and ObjVal.type.pointee == struct_type: + call_self = ObjVal + else: + call_self = Gen.builder.bitcast(ObjVal, self_ptr_type, name=f"method_self_{ClassName}") + call_args_fb = [call_self] + CallArgs + self._fill_default_args(call_args_fb, func, BareFuncName) + self._append_eh_msg_out_arg(call_args_fb, func, Gen) + adjusted = Gen._adjust_args(call_args_fb, func) + return Gen.builder.call(func, adjusted, name=f"call_{BareFuncName}") raise Exception(f"Undefined method '{MethodName}' in class '{ClassName}' (no function declaration found for '{FullMethodName}')") def _EnsureReceiverStructConcrete(self, ClassName: str, class_sha1: str | None, ObjVal: Any, Gen: "LlvmGeneratorMixin") -> Any: