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]