Commit 4e289013 authored by Tom Niget's avatar Tom Niget

Fix TypeVar instantiation

parent b4c7b909
......@@ -65,14 +65,11 @@ class StdlibVisitor(NodeVisitorSeq):
ty = FunctionType(arg_types, ret_type)
if node.args.vararg:
ty.variadic = True
#arg_types.append(TY_VARARG)
if self.cur_class:
assert isinstance(self.cur_class, TypeType)
if isinstance(self.cur_class.type_object, ABCMeta):
self.cur_class.type_object.gen_methods[node.name] = lambda t: ty.gen_sub(t, self.typevars)
else:
# ty_inst = FunctionType(arg_types[1:], ret_type)
# self.cur_class.args[0].add_inst_member(node.name, ty_inst)
self.cur_class.type_object.methods[node.name] = ty.gen_sub(self.cur_class.type_object, self.typevars)
self.scope.vars[node.name] = VarDecl(VarKind.LOCAL, ty)
......@@ -81,9 +78,9 @@ class StdlibVisitor(NodeVisitorSeq):
def visit_Call(self, node: ast.Call) -> BaseType:
ty_op = self.visit(node.func)
if isinstance(ty_op, type):
return ty_op(*[ast.literal_eval(arg) for arg in node.args])
raise NotImplementedError
if isinstance(ty_op, TypeType):
return ty_op.type_object(*[ast.literal_eval(arg) for arg in node.args])
raise NotImplementedError(ast.unparse(node))
def anno(self) -> "TypeAnnotationVisitor":
return TypeAnnotationVisitor(self.scope, self.cur_class)
......
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