1.1 --- a/resolving.py Sun Sep 04 22:36:15 2016 +0200
1.2 +++ b/resolving.py Sun Sep 04 23:55:15 2016 +0200
1.3 @@ -46,9 +46,9 @@
1.4 def get_resolved_object(self, path):
1.5
1.6 """
1.7 - Get the details of an object with the given 'path'. Where the object
1.8 - has not been resolved, None is returned. This differs from the
1.9 - get_object method used elsewhere in that it does not return an
1.10 + Get the details of an object with the given 'path' within this module.
1.11 + Where the object has not been resolved, None is returned. This differs
1.12 + from the get_object method used elsewhere in that it does not return an
1.13 unresolved object reference.
1.14 """
1.15
1.16 @@ -61,6 +61,12 @@
1.17 else:
1.18 return None
1.19
1.20 + def get_resolved_global_or_builtin(self, name):
1.21 +
1.22 + "Return the resolved global or built-in object with the given 'name'."
1.23 +
1.24 + return self.get_global(name) or self.importer.get_object("__builtins__.%s" % name)
1.25 +
1.26 # Post-inspection resolution activities.
1.27
1.28 def resolve(self):
1.29 @@ -82,6 +88,9 @@
1.30 for name, ref in self.objects.items():
1.31 if ref.has_kind("<depends>"):
1.32 ref = self.importer.get_object(name)
1.33 +
1.34 + # Alias the member and write back to the importer.
1.35 +
1.36 ref = ref.alias(name)
1.37 self.importer.objects[name] = self.objects[name] = ref
1.38
1.39 @@ -148,7 +157,7 @@
1.40
1.41 # Find global or built-in definitions.
1.42
1.43 - ref = self.get_global_or_builtin(name)
1.44 + ref = self.get_resolved_global_or_builtin(name)
1.45 objpath = ref and (ref.final() or ref.get_name())
1.46 if objpath:
1.47 self.name_references[key] = objpath
1.48 @@ -349,6 +358,13 @@
1.49 else:
1.50 continue
1.51
1.52 + # Resolve any hidden dependencies involving external objects
1.53 + # or unresolved names referring to globals or built-ins.
1.54 +
1.55 + if ref.has_kind("<depends>"):
1.56 + ref = self.importer.get_object(ref.get_origin()) or \
1.57 + self.importer.get_object(self.name_references.get(ref.get_origin()))
1.58 +
1.59 # Convert class invocations to instances.
1.60
1.61 if invocation: