Commit f1dd801a authored by Tom Niget's avatar Tom Niget

Fix Self substitution for generics

parent aec0e5c2
...@@ -104,7 +104,7 @@ class ScoperExprVisitor(ScoperVisitor): ...@@ -104,7 +104,7 @@ class ScoperExprVisitor(ScoperVisitor):
def visit_Call(self, node: ast.Call) -> BaseType: def visit_Call(self, node: ast.Call) -> BaseType:
ftype = self.visit(node.func) ftype = self.visit(node.func)
if ftype.typevars: if ftype.typevars:
ftype = ftype.gen_sub(ftype, {v.name: TypeVariable(v.name) for v in ftype.typevars}) ftype = ftype.gen_sub(None, {v.name: TypeVariable(v.name) for v in ftype.typevars})
rtype = self.visit_function_call(ftype, [self.visit(arg) for arg in node.args]) rtype = self.visit_function_call(ftype, [self.visit(arg) for arg in node.args])
actual = rtype actual = rtype
node.is_await = False node.is_await = False
......
...@@ -345,8 +345,9 @@ class TypeType(TypeOperator): ...@@ -345,8 +345,9 @@ class TypeType(TypeOperator):
TY_SELF = TypeOperator.make_type("Self") TY_SELF = TypeOperator.make_type("Self")
def self_gen_sub(this, typevars, _): def self_gen_sub(this, typevars, _):
assert this is not None if this is not None:
return this return this
return TY_SELF
TY_SELF.gen_sub = self_gen_sub TY_SELF.gen_sub = self_gen_sub
TY_BOOL = TypeOperator.make_type("bool") TY_BOOL = TypeOperator.make_type("bool")
DEFAULT_EQ = FunctionType([TY_SELF, TY_SELF], TY_BOOL) DEFAULT_EQ = FunctionType([TY_SELF, TY_SELF], TY_BOOL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment