fix(checker): handle nested generic members

This commit is contained in:
2026-06-12 16:53:34 +02:00
parent 200709cca6
commit 12d034fd1e
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -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]