Skip to content

Commit

Permalink
Rename method name to param_type.
Browse files Browse the repository at this point in the history
The `node_type` is used practically only for method arguments.
Change the name to make the difference between `literal_to_type` and `node_type` clearer.
  • Loading branch information
ksss committed Mar 24, 2022
1 parent d274c72 commit 7964e67
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rbs/prototype/rb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def function_type_from_body(node, def_name)
name = lvasgn.children[0]
fun.optional_positionals << Types::Function::Param.new(
name: name,
type: node_type(lvasgn.children[1])
type: param_type(lvasgn.children[1])
)
end

Expand All @@ -429,7 +429,7 @@ def function_type_from_body(node, def_name)
when nil, :NODE_SPECIAL_REQUIRED_KEYWORD
fun.required_keywords[name] = Types::Function::Param.new(name: name, type: untyped)
when RubyVM::AbstractSyntaxTree::Node
fun.optional_keywords[name] = Types::Function::Param.new(name: name, type: node_type(value))
fun.optional_keywords[name] = Types::Function::Param.new(name: name, type: param_type(value))
else
raise "Unexpected keyword arg value: #{value}"
end
Expand Down Expand Up @@ -578,7 +578,7 @@ def range_element_type(types)
end
end

def node_type(node, default: Types::Bases::Any.new(location: nil))
def param_type(node, default: Types::Bases::Any.new(location: nil))
case node.type
when :LIT
case node.children[0]
Expand Down Expand Up @@ -610,6 +610,9 @@ def node_type(node, default: Types::Bases::Any.new(location: nil))
end
end

# backward compatible
alias node_type param_type

def private
@private ||= AST::Members::Private.new(location: nil)
end
Expand Down

0 comments on commit 7964e67

Please sign in to comment.