# HG changeset patch # User Paul Boddie # Date 1473434520 -7200 # Node ID 011a7abf698c19ae1063c3401c845108aec55f10 # Parent 8f8e85368db9dcce702f580794e582009562c011 Exclude "self" from method parameters but include it in method locals. diff -r 8f8e85368db9 -r 011a7abf698c inspector.py --- a/inspector.py Thu Sep 08 23:59:54 2016 +0200 +++ b/inspector.py Fri Sep 09 17:22:00 2016 +0200 @@ -555,24 +555,32 @@ function_name = self.get_object_path(name) argnames = get_argnames(n.argnames) + is_method = self.in_class and not self.in_function - # Insert "self" into methods where not explicitly declared. + # Remove explicit "self" from method parameters. - if self.in_class and (not argnames or argnames[0] != "self"): - argnames.insert(0, "self") + if is_method and argnames and argnames[0] == "self": + del argnames[0] + + # Copy and propagate the parameters. self.importer.function_parameters[function_name] = \ - self.function_parameters[function_name] = argnames + self.function_parameters[function_name] = argnames[:] # Define all arguments/parameters in the local namespace. locals = self.function_locals[function_name] = {} + # Insert "self" into method locals. + + if is_method: + argnames.insert(0, "self") + # Define "self" in terms of the class if in a method. # This does not diminish the need for type-narrowing in the deducer. if argnames: - if self.in_class and argnames[0] == "self": + if self.in_class and not self.in_function and argnames[0] == "self": locals[argnames[0]] = Reference("", self.in_class) else: locals[argnames[0]] = Reference("")