Method: RBS::Resolver::ConstantResolver#load_child_constants

Defined in:
lib/rbs/resolver/constant_resolver.rb

#load_child_constants(name) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/rbs/resolver/constant_resolver.rb', line 138

def load_child_constants(name)
  # @type var constants: Hash[Symbol, Constant]
  constants = {}

  if table.children(name)
    builder.ancestor_builder.instance_ancestors(name).ancestors.reverse_each do |ancestor|
      if ancestor.is_a?(Definition::Ancestor::Instance)
        if ancestor.name == BuiltinNames::Object.name
          if name != BuiltinNames::Object.name
            next
          end
        end

        case ancestor.source
        when AST::Members::Include, :super, nil
          consts = table.children(ancestor.name) or raise
          constants.merge!(consts)
        end
      end
    end
  end

  child_constants_cache[name] = constants
end