From 12d034fd1e9db1431121f7b7a7b54b7301a56c18 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Fri, 12 Jun 2026 16:53:34 +0200 Subject: [PATCH] fix(checker): handle nested generic members --- midas/checker/registry.py | 6 ++++++ midas/checker/types.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/midas/checker/registry.py b/midas/checker/registry.py index db2f972..7ed206d 100644 --- a/midas/checker/registry.py +++ b/midas/checker/registry.py @@ -13,6 +13,7 @@ from midas.checker.types import ( Operation, OverloadedFunction, Type, + TypeVar, UnknownType, substitute_typevars, ) @@ -171,6 +172,11 @@ class TypesRegistry: case (Function(), Function()): return self.is_func_subtype(type1, type2) + case (TypeVar(bound=bound), _): + if bound is None: + return False + return self.is_subtype(bound, type2) + return False # TODO: verify the logic in here diff --git a/midas/checker/types.py b/midas/checker/types.py index dd8c173..d0dbe2f 100644 --- a/midas/checker/types.py +++ b/midas/checker/types.py @@ -191,6 +191,13 @@ def substitute_typevars(type: Type, substitutions: dict[str, Type]) -> Type: ), ) + case AppliedType(name=name, args=args, body=body): + return AppliedType( + name=name, + args=[substitute_typevars(arg, substitutions) for arg in args], + body=substitute_typevars(body, substitutions), + ) + case TypeVar(name=name): if name in substitutions: return substitutions[name]