1.1 --- a/inspector.py Thu Sep 08 23:59:54 2016 +0200
1.2 +++ b/inspector.py Fri Sep 09 17:22:00 2016 +0200
1.3 @@ -555,24 +555,32 @@
1.4
1.5 function_name = self.get_object_path(name)
1.6 argnames = get_argnames(n.argnames)
1.7 + is_method = self.in_class and not self.in_function
1.8
1.9 - # Insert "self" into methods where not explicitly declared.
1.10 + # Remove explicit "self" from method parameters.
1.11
1.12 - if self.in_class and (not argnames or argnames[0] != "self"):
1.13 - argnames.insert(0, "self")
1.14 + if is_method and argnames and argnames[0] == "self":
1.15 + del argnames[0]
1.16 +
1.17 + # Copy and propagate the parameters.
1.18
1.19 self.importer.function_parameters[function_name] = \
1.20 - self.function_parameters[function_name] = argnames
1.21 + self.function_parameters[function_name] = argnames[:]
1.22
1.23 # Define all arguments/parameters in the local namespace.
1.24
1.25 locals = self.function_locals[function_name] = {}
1.26
1.27 + # Insert "self" into method locals.
1.28 +
1.29 + if is_method:
1.30 + argnames.insert(0, "self")
1.31 +
1.32 # Define "self" in terms of the class if in a method.
1.33 # This does not diminish the need for type-narrowing in the deducer.
1.34
1.35 if argnames:
1.36 - if self.in_class and argnames[0] == "self":
1.37 + if self.in_class and not self.in_function and argnames[0] == "self":
1.38 locals[argnames[0]] = Reference("<instance>", self.in_class)
1.39 else:
1.40 locals[argnames[0]] = Reference("<var>")