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.



83
84
85
86
87
88
89
# File 'lib/steep/type_inference/method_call.rb', line 83

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.



78
79
80
# File 'lib/steep/type_inference/method_call.rb', line 78

def context
  @context
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



79
80
81
# File 'lib/steep/type_inference/method_call.rb', line 79

def method_name
  @method_name
end

#nodeObject (readonly)

Returns the value of attribute node.



77
78
79
# File 'lib/steep/type_inference/method_call.rb', line 77

def node
  @node
end

#receiver_typeObject (readonly)

Returns the value of attribute receiver_type.



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

def receiver_type
  @receiver_type
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



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

def return_type
  @return_type
end

Instance Method Details

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



99
100
101
102
103
104
105
106
# File 'lib/steep/type_inference/method_call.rb', line 99

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



110
111
112
# File 'lib/steep/type_inference/method_call.rb', line 110

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

#with_return_type(new_type) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/steep/type_inference/method_call.rb', line 91

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