@@ -248,6 +248,16 @@ def find_attr_arguments(insns, index)
248248 names if insns [ current ] == [ :putself ] && names . length == orig_argc
249249 end
250250
251+ def method_definition ( nesting , name , location , file_comments )
252+ comments = EntryComments . new ( file_comments , location )
253+
254+ if nesting . last == [ :singletonclass ]
255+ SingletonMethodDefinition . new ( nesting [ 0 ...-1 ] , name , location , comments )
256+ else
257+ MethodDefinition . new ( nesting , name , location , comments )
258+ end
259+ end
260+
251261 def index_iseq ( iseq , file_comments )
252262 results = [ ]
253263 queue = [ [ iseq , [ ] ] ]
@@ -331,12 +341,7 @@ def index_iseq(iseq, file_comments)
331341 queue << [ class_iseq , next_nesting ]
332342 when :definemethod
333343 location = location_for ( insn [ 2 ] )
334- results << MethodDefinition . new (
335- current_nesting ,
336- insn [ 1 ] ,
337- location ,
338- EntryComments . new ( file_comments , location )
339- )
344+ results << method_definition ( current_nesting , insn [ 1 ] , location , file_comments )
340345 when :definesmethod
341346 if insns [ index - 1 ] != [ :putself ]
342347 raise NotImplementedError ,
@@ -373,21 +378,11 @@ def index_iseq(iseq, file_comments)
373378 location = Location . new ( line , 0 )
374379 names . each do |name |
375380 if insn [ 1 ] [ :mid ] != :attr_writer
376- results << MethodDefinition . new (
377- current_nesting ,
378- name ,
379- location ,
380- EntryComments . new ( file_comments , location )
381- )
381+ results << method_definition ( current_nesting , name , location , file_comments )
382382 end
383383
384384 if insn [ 1 ] [ :mid ] != :attr_reader
385- results << MethodDefinition . new (
386- current_nesting ,
387- :"#{ name } =" ,
388- location ,
389- EntryComments . new ( file_comments , location )
390- )
385+ results << method_definition ( current_nesting , :"#{ name } =" , location , file_comments )
391386 end
392387 end
393388 when :"core#set_method_alias"
0 commit comments