Class: Rigor::Cache::RbsClassTypeParamNames

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/cache/rbs_class_type_param_names.rb

Overview

Cache producer that materialises every loaded class’s RBS-declared type-parameter names as a Marshal-clean ‘Hash<String, Array<Symbol>>` keyed by top-level-stripped class name (e.g. `“Array”` → `[:Elem]`, `“Hash”` →`[:K, :V]`). Producer id `“rbs.class_type_param_names”`.

The dispatcher reads type-parameter names every time it builds a substitution map from a receiver’s ‘type_args` into a method’s return type — it is one of the hottest reflection lookups during analysis. Building one entry requires a full ‘RBS::DefinitionBuilder#build_instance` over that class, the same expensive operation RbsClassAncestorTable caches; the two producers share the build cost when populated together.

Cache descriptor shape is shared with every other cache producer that depends on the RBS environment — see Rigor::Cache::RbsDescriptor.build.

Constant Summary collapse

PRODUCER_ID =
"rbs.class_type_param_names"

Class Method Summary collapse

Class Method Details

.fetch(loader:, store:) ⇒ Hash{String => Array<Symbol>}

Parameters:

Returns:

  • (Hash{String => Array<Symbol>})


31
32
33
34
35
36
# File 'lib/rigor/cache/rbs_class_type_param_names.rb', line 31

def self.fetch(loader:, store:)
  descriptor = RbsDescriptor.build(loader)
  store.fetch_or_compute(producer_id: PRODUCER_ID, params: {}, descriptor: descriptor) do
    compute(loader)
  end
end