Class: Rigor::Inference::ProjectPatchedMethods
- Inherits:
-
Object
- Object
- Rigor::Inference::ProjectPatchedMethods
- Defined in:
- lib/rigor/inference/project_patched_methods.rb
Overview
ADR-17 § “Inference contract” — project-wide patched-method registry populated by the pre-eval pre-pass (slice 2) from the user’s ‘.rigor.yml` `pre_eval:` list.
Each entry records one ‘def` declaration the pre-pass observed inside a class / module body. The dispatcher’s ‘try_project_patched_method` tier consults this registry between the plugin tier and the dependency-source tier so project-side `lib/core_ext/string_extensions.rb` patches are visible to cross-file dispatch.
Slice 2 ships the registry at the floor: the dispatcher answers ‘Type::Combinator.untyped` (Dynamic) on a hit; return-type inference for patched methods stays deferred (a separate slice when concrete demand surfaces — most real-world `core_ext` patches return shapes the analyzer could heuristically extract via the same machinery the ADR-10 walker uses, but slice 2 keeps the surface narrow).
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- EMPTY =
new.freeze
Instance Attribute Summary collapse
-
#by_key ⇒ Object
readonly
Returns the value of attribute by_key.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(entries: []) ⇒ ProjectPatchedMethods
constructor
A new instance of ProjectPatchedMethods.
-
#lookup(class_name:, method_name:, kind:) ⇒ Entry?
The recorded entry for the given ‘(class_name, method_name, kind)` triple, or `nil` when no pre-eval file declared it.
Constructor Details
#initialize(entries: []) ⇒ ProjectPatchedMethods
Returns a new instance of ProjectPatchedMethods.
48 49 50 51 52 53 54 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 48 def initialize(entries: []) @by_key = entries.each_with_object({}) do |entry, acc| key = [entry.class_name, entry.method_name, entry.kind] acc[key] ||= entry end.freeze freeze end |
Instance Attribute Details
#by_key ⇒ Object (readonly)
Returns the value of attribute by_key.
41 42 43 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 41 def by_key @by_key end |
Instance Method Details
#empty? ⇒ Boolean
63 64 65 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 63 def empty? @by_key.empty? end |
#lookup(class_name:, method_name:, kind:) ⇒ Entry?
Returns the recorded entry for the given ‘(class_name, method_name, kind)` triple, or `nil` when no pre-eval file declared it.
59 60 61 |
# File 'lib/rigor/inference/project_patched_methods.rb', line 59 def lookup(class_name:, method_name:, kind:) @by_key[[class_name, method_name, kind]] end |