# HG changeset patch # User Paul Boddie # Date 1315258202 -7200 # Node ID 3a679e21fb5a713f19b7092abb04a2e1abb37343 # Parent d5eaebe4e28e427cae8e5c01d5981816a240acbc Added a restriction on the possible types involved where attributes are accessed via "self", using the parent class and its descendants to filter the deduced set of types. diff -r d5eaebe4e28e -r 3a679e21fb5a micropython/__init__.py --- a/micropython/__init__.py Mon Sep 05 00:57:24 2011 +0200 +++ b/micropython/__init__.py Mon Sep 05 23:30:02 2011 +0200 @@ -620,9 +620,23 @@ all_objtypes = get_object_types_for_usage(usage, objtable, name, from_name) + # Where the name through which the attributes are accessed is the + # special "self" name, restrict the possibilities to types + # appropriate for the method involved. + + if name == "self" and user and user.unit and user.unit.is_method(): + cls = user.unit.parent + descendants = cls.all_descendants() + valid_objtypes = [] + for objname, is_static in all_objtypes: + if objname == cls.full_name() or objname in descendants: + valid_objtypes.append((objname, is_static)) + else: + valid_objtypes = all_objtypes + # Investigate the object types. - self._collect_attributes_for_types(from_name, objtable, all_objtypes, usage) + self._collect_attributes_for_types(from_name, objtable, valid_objtypes, usage) # Get specific name references and visit the referenced objects.