Class: Steep::TypeInference::MethodCall::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/type_inference/method_call.rb

Direct Known Subclasses

Error, NoMethodError, Typed, Untyped

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:, context:, method_name:, receiver_type:, return_type:) ⇒ Base

Returns a new instance of Base.



87
88
89
90
91
92
93
# File 'lib/steep/type_inference/method_call.rb', line 87

def initialize(node:, context:, method_name:, receiver_type:, return_type:)
  @node = node
  @context = context
  @method_name = method_name
  @receiver_type = receiver_type
  @return_type = return_type
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



82
83
84
# File 'lib/steep/type_inference/method_call.rb', line 82

def context
  @context
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



83
84
85
# File 'lib/steep/type_inference/method_call.rb', line 83

def method_name
  @method_name
end

#nodeObject (readonly)

Returns the value of attribute node.



81
82
83
# File 'lib/steep/type_inference/method_call.rb', line 81

def node
  @node
end

#receiver_typeObject (readonly)

Returns the value of attribute receiver_type.



85
86
87
# File 'lib/steep/type_inference/method_call.rb', line 85

def receiver_type
  @receiver_type
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



84
85
86
# File 'lib/steep/type_inference/method_call.rb', line 84

def return_type
  @return_type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



103
104
105
106
107
108
109
110
# File 'lib/steep/type_inference/method_call.rb', line 103

def ==(other)
  other.is_a?(Base) &&
    other.node == node &&
    other.context == context &&
    other.method_name == method_name &&
    other.return_type == return_type &&
    other.receiver_type == receiver_type
end

#hashObject



114
115
116
# File 'lib/steep/type_inference/method_call.rb', line 114

def hash
  node.hash ^ context.hash ^ method_name.hash ^ return_type.hash ^ receiver_type.hash
end

#with_return_type(new_type) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/steep/type_inference/method_call.rb', line 95

def with_return_type(new_type)
  dup.tap do |copy|
    copy.instance_eval do
      @return_type = new_type
    end
  end
end