Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/typeprof/core/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ def superclass_source_is_toplevel?(const_node)
def dump_declarations(path)
stack = []
out = []
seen_consts = Set.empty
@rb_text_nodes[path]&.traverse do |event, node|
case node
when AST::ModuleNode
Expand Down Expand Up @@ -508,7 +509,14 @@ def dump_declarations(path)
when AST::ConstantWriteNode
if node.static_cpath
if event == :enter
out << " " * stack.size + "#{ format_declared_const_path(node.static_cpath, stack) }: #{ node.ret.show }"
unless seen_consts.include?(node.static_cpath)
seen_consts << node.static_cpath
cdef = @genv.resolve_const(node.static_cpath)
# Use the assigned value for a single write so a same-named class
# or module (e.g. declared in RBS) is not mixed in; union the types otherwise.
ret = cdef.defs.size > 1 ? cdef.vtx : node.ret
out << " " * stack.size + "#{ format_declared_const_path(node.static_cpath, stack) }: #{ ret.show }"
end
end
end
else
Expand Down
2 changes: 0 additions & 2 deletions scenario/variable/operator_write.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def test_attr=(x)
## diagnostics
## assert
class C
D: Integer
D: Integer
def get_lv: -> Integer
def set_iv: -> Integer
Expand All @@ -56,4 +55,3 @@ def test_attr: -> Integer
def test_attr=: (Integer) -> Integer
end
C::E: Integer
C::E: Integer
Loading