From 10b3f90a2429058fb2de8b2435b8c198df2ee8b0 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 18 Oct 2026 18:32:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(generic):=20=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E7=BC=BA=E5=B0=91=E7=89=B9=E5=8C=96=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=88=99=E4=BB=8E=E5=A4=B4=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit list[AST*].get 等特化方法未生成时,调用 _specialize_generic_class 补全整个特化,而不只处理 declare_only 缓存。 --- lib/core/Handles/HandlesExprCall.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/Handles/HandlesExprCall.py b/lib/core/Handles/HandlesExprCall.py index 892ff57..a7c4f73 100644 --- a/lib/core/Handles/HandlesExprCall.py +++ b/lib/core/Handles/HandlesExprCall.py @@ -3018,6 +3018,13 @@ class ExprCallHandle(BaseHandle): spec_cache = getattr(Gen, '_generic_class_specializations', {}) cached = spec_cache.get(spec_key) if not isinstance(cached, tuple) or len(cached) < 2: + # 缓存中还没有该特化:直接从头生成完整特化(方法体随类特化一起产出) + try: + self.Trans.ClassHandler._specialize_generic_class( + base_name, ClassName[len(base_name) + 1:-1].split(']['), + Gen, declare_only=False) + except Exception: + pass return cached_name: str = cached[0] was_declare_only: bool = cached[1]