Skip to content

Commit a64531f

Browse files
committed
Record method definitions via accessors
1 parent 98f5949 commit a64531f

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/steep/type_construction.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,6 +3366,23 @@ def type_send(node, send_node:, block_params:, block_body:, unwrap: false, tapp:
33663366
constr = self
33673367
else
33683368
receiver, method_name, *arguments = send_node.children
3369+
3370+
case method_name
3371+
when :attr_reader
3372+
arguments.each do |argnode|
3373+
module_context.defined_instance_methods << argnode.children[0]
3374+
end
3375+
when :attr_writer
3376+
arguments.each do |argnode|
3377+
module_context.defined_instance_methods << :"#{argnode.children[0]}="
3378+
end
3379+
when :attr_accessor
3380+
arguments.each do |argnode|
3381+
module_context.defined_instance_methods << argnode.children[0]
3382+
module_context.defined_instance_methods << :"#{argnode.children[0]}="
3383+
end
3384+
end
3385+
33693386
if receiver
33703387
recv_type, constr = synthesize(receiver)
33713388
else

smoke/diagnostics/a.rbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ end
44

55
class MethodDefinitionMissing
66
def foo: () -> void
7+
8+
attr_reader bar: untyped
9+
attr_writer baz: untyped
10+
attr_accessor qux: untyped
711
end
812

913
class UnexpectedDynamicMethod
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
class MethodDefinitionMissing
2+
attr_reader :bar
3+
attr_writer :baz
4+
attr_accessor :qux
5+
6+
def hoge
7+
end
28
end

0 commit comments

Comments
 (0)