Class: Rigor::Inference::MethodParameterBinder
- Inherits:
-
Object
- Object
- Rigor::Inference::MethodParameterBinder
- Defined in:
- lib/rigor/inference/method_parameter_binder.rb,
sig/rigor/inference.rbs
Instance Method Summary collapse
-
#bind(def_node) ⇒ Hash{Symbol => Rigor::Type}
Ordered map from parameter name to bound type.
-
#initialize(environment:, class_path:, singleton:, source_path: nil) ⇒ MethodParameterBinder
constructor
A new instance of MethodParameterBinder.
Constructor Details
#initialize(environment:, class_path:, singleton:, source_path: nil) ⇒ MethodParameterBinder
Returns a new instance of MethodParameterBinder.
68 69 70 71 72 73 |
# File 'lib/rigor/inference/method_parameter_binder.rb', line 68 def initialize(environment:, class_path:, singleton:, source_path: nil) @environment = environment @class_path = class_path @singleton = singleton @source_path = source_path end |
Instance Method Details
#bind(def_node) ⇒ Hash{Symbol => Rigor::Type}
Returns ordered map from parameter name to bound type.
Anonymous parameters (* and ** without a name) are skipped.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rigor/inference/method_parameter_binder.rb', line 78 def bind(def_node) slots = collect_slots(def_node.parameters) types = default_types_for(slots) rbs_method = lookup_rbs_method(def_node) if rbs_method apply_rbs_overloads(types, slots, rbs_method.method_types) unless rbs_method.method_types.empty? # `rigor:v1:param: <name> <refinement>` annotations tighten the bound type for matching # slots. Applied after the RBS-overload pass so the override is the authoritative # answer regardless of what the RBS signature declared. apply_param_overrides(types, slots, rbs_method) end # ADR-28 — a path-scoped protocol contract supplies the parameter type for a matching # `def`. Applied last (most authoritative) and regardless of RBS presence: the methods a # contract targets — controller actions and the like — typically have no RBS signature # at all, so this tier must run even when `rbs_method` is nil. apply_protocol_contract(types, slots, def_node) types end |