Class: Yoda::Typing::Inferencer::ArgumentsBinder

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/typing/inferencer/arguments_binder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generator:) ⇒ ArgumentsBinder

Returns a new instance of ArgumentsBinder.

Parameters:



9
10
11
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 9

def initialize(generator:)
  @generator = generator
end

Instance Attribute Details

#generatorTypes::Generator (readonly)

Returns:



6
7
8
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 6

def generator
  @generator
end

Instance Method Details

#bind(types:, arguments:) ⇒ Hash{ Symbol => Types::Type }

Parameters:

Returns:



16
17
18
19
20
# File 'lib/yoda/typing/inferencer/arguments_binder.rb', line 16

def bind(types:, arguments:)
  binds = types.map { |type| ParameterBinder.new(arguments).bind(type: type, generator: generator) }
  # @todo Select only one signature to bind arguments
  binds.reduce({}) { |memo, bind| memo.merge!(bind.to_h) { |_key, v1, v2| generator.union_type(v1, v2) } }
end