Skip to content

Commit

Permalink
Delete unused self_class? method
Browse files Browse the repository at this point in the history
The type of `#class` returns correct types now.
  • Loading branch information
soutaro committed Sep 19, 2024
1 parent c515361 commit 76fb79d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
31 changes: 2 additions & 29 deletions lib/steep/type_construction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2657,34 +2657,11 @@ def check(node, type, constraints: Subtyping::Constraints.empty)
def synthesize_sendish(node, hint:, tapp:)
case node.type
when :send
yield_self do
if self_class?(node)
module_type = expand_alias(module_context.module_type)
type = if module_type.is_a?(AST::Types::Name::Singleton)
AST::Types::Name::Singleton.new(name: module_type.name)
else
module_type
end

add_typing(node, type: type)
else
type_send(node, send_node: node, block_params: nil, block_body: nil, tapp: tapp, hint: hint)
end
end
type_send(node, send_node: node, block_params: nil, block_body: nil, tapp: tapp, hint: hint)
when :csend
yield_self do
send_type, constr =
if self_class?(node)
module_type = expand_alias(module_context.module_type)
type = if module_type.is_a?(AST::Types::Name::Singleton)
AST::Types::Name::Singleton.new(name: module_type.name)
else
module_type
end
add_typing(node, type: type).to_ary
else
type_send(node, send_node: node, block_params: nil, block_body: nil, unwrap: true, tapp: tapp, hint: hint).to_ary
end
type_send(node, send_node: node, block_params: nil, block_body: nil, unwrap: true, tapp: tapp, hint: hint).to_ary

constr
.update_type_env { context.type_env.join(constr.context.type_env, context.type_env) }
Expand Down Expand Up @@ -4687,10 +4664,6 @@ def fallback_to_any(node)
add_typing node, type: AST::Builtin.any_type
end

def self_class?(node)
node.type == :send && node.children[0]&.type == :self && node.children[1] == :class
end

def namespace_module?(node)
# @type var nodes: Array[Parser::AST::Node]
nodes =
Expand Down
3 changes: 0 additions & 3 deletions sig/steep/type_construction.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ module Steep

def fallback_to_any: (Parser::AST::Node node) ?{ () -> Diagnostic::Ruby::Base } -> Pair

# Return `true` if `node` is `self.class`
def self_class?: (Parser::AST::Node node) -> bool

# Returns `true` if the given `node` is a `class` or `module` declaration that only contains module/class definitions
#
def namespace_module?: (Parser::AST::Node node) -> bool
Expand Down

0 comments on commit 76fb79d

Please sign in to comment.