fix(checker): handle nested generic members
This commit is contained in:
@@ -13,6 +13,7 @@ from midas.checker.types import (
|
|||||||
Operation,
|
Operation,
|
||||||
OverloadedFunction,
|
OverloadedFunction,
|
||||||
Type,
|
Type,
|
||||||
|
TypeVar,
|
||||||
UnknownType,
|
UnknownType,
|
||||||
substitute_typevars,
|
substitute_typevars,
|
||||||
)
|
)
|
||||||
@@ -171,6 +172,11 @@ class TypesRegistry:
|
|||||||
case (Function(), Function()):
|
case (Function(), Function()):
|
||||||
return self.is_func_subtype(type1, type2)
|
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
|
return False
|
||||||
|
|
||||||
# TODO: verify the logic in here
|
# 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):
|
case TypeVar(name=name):
|
||||||
if name in substitutions:
|
if name in substitutions:
|
||||||
return substitutions[name]
|
return substitutions[name]
|
||||||
|
|||||||
Reference in New Issue
Block a user