Commit c5aae2f9 authored by Tom Niget's avatar Tom Niget

Fix Self substitution for generics

parent 30dc6b3a
......@@ -104,7 +104,7 @@ class ScoperExprVisitor(ScoperVisitor):
def visit_Call(self, node: ast.Call) -> BaseType:
ftype = self.visit(node.func)
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])
actual = rtype
node.is_await = False
......
......@@ -345,8 +345,9 @@ class TypeType(TypeOperator):
TY_SELF = TypeOperator.make_type("Self")
def self_gen_sub(this, typevars, _):
assert this is not None
return this
if this is not None:
return this
return TY_SELF
TY_SELF.gen_sub = self_gen_sub
TY_BOOL = TypeOperator.make_type("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