callee_type = self.fix_bound_init_tvars(callee_type, map_instance_to_supertype(selftype, info.base)) super_init = (FuncDef)info.base.get_method('__init__') # Build argument list. args = [Var('self')] for i in range(1, len(super_init.args)): args.append(Var(super_init.args[i].name())) args[-1].type = callee_type.arg_types[i - 1] selft = self_type(self.tf.type_context()) callee_type = prepend_arg_type(callee_type, selft) creat = FuncDef('__init__', args, super_init.arg_kinds, <Node> [None] * len(args), Block([])) creat.info = tdef.info creat.type = callee_type creat.is_implicit = False tdef.info.methods['__init__'] = creat # Insert a call to superclass constructor. If the # superclass is object, the constructor does nothing => # omit the call. if tdef.info.base.full_name() != 'builtins.object': creat.body.body.append( self.make_superclass_constructor_call(tdef.info, callee_type)) # Implicit cast from FuncDef[] to Node[] is safe below.