fix(checker): handle nested generic members
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user