Lichen

Changeset

890:2cbff01cc586
2019-02-02 Paul Boddie raw files shortlog changelog graph Introduced special case treatment of __class__ as a ubiquitous attribute.
deducer.py (file)
     1.1 --- a/deducer.py	Sat Feb 02 01:18:52 2019 +0100
     1.2 +++ b/deducer.py	Sat Feb 02 17:54:22 2019 +0100
     1.3 @@ -2347,6 +2347,10 @@
     1.4          remaining = attrnames.split(".")
     1.5          attrname = remaining[0]
     1.6  
     1.7 +        # Special case for the ubiquitous __class__ attribute.
     1.8 +
     1.9 +        ubiquitous = attrname == "__class__"
    1.10 +
    1.11          # Obtain reference, provider and provider kind information.
    1.12  
    1.13          attrs = self.reference_all_attrs[location]
    1.14 @@ -2375,8 +2379,8 @@
    1.15  
    1.16          # Determine how attributes may be accessed relative to the accessor.
    1.17  
    1.18 -        object_relative = class_accessor or module_accessor or provided_by_instance
    1.19 -        class_relative = instance_accessor and provided_by_class
    1.20 +        object_relative = ubiquitous or class_accessor or module_accessor or provided_by_instance
    1.21 +        class_relative = not ubiquitous and instance_accessor and provided_by_class
    1.22  
    1.23          # Identify the last static attribute for context acquisition.
    1.24  
    1.25 @@ -2517,6 +2521,11 @@
    1.26              first_method = "relative" + (object_relative and "-object" or "") + \
    1.27                                          (class_relative and "-class" or "")
    1.28  
    1.29 +        # Special case for the ubiquitous __class__ attribute.
    1.30 +
    1.31 +        elif ubiquitous:
    1.32 +            first_method = "relative-object"
    1.33 +
    1.34          # The fallback case is always run-time testing and access.
    1.35  
    1.36          else: