Commit 6374abcf authored by Tom Niget's avatar Tom Niget

Fix substitution of Self type in functions

parent 3b51dc29
......@@ -105,7 +105,7 @@ class ScoperExprVisitor(ScoperVisitor):
def visit_Call(self, node: ast.Call) -> BaseType:
ftype = self.visit(node.func)
if ftype.typevars:
ftype = ftype.gen_sub(None, {v.name: TypeVariable(v.name) for v in ftype.typevars})
ftype = ftype.gen_sub(ftype, {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
......@@ -174,6 +174,7 @@ class ScoperExprVisitor(ScoperVisitor):
attr.python_func_used = True
return attr
if meth := ltype.methods.get(name):
meth = meth.gen_sub(ltype, {})
if bound:
return meth.remove_self()
else:
......
......@@ -241,9 +241,10 @@ class TypeOperator(BaseType, ABC):
return me
if len(self.args) == 0:
return self
assert all(x is not None for x in self.args)
res = object.__new__(self.__class__) # todo: ugly... should make a clone()
cache[self] = res
if isinstance(this, TypeOperator):
if isinstance(this, TypeOperator) and not isinstance(this, FunctionType):
vardict = dict(zip(typevars.keys(), this.args))
else:
vardict = typevars
......
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