Skip to content
  • nagachika's avatar
    c98aa2db
    merge revision(s) c60aaed1: [Backport #17130] · c98aa2db
    nagachika authored
    	Fix Method#super_method for aliased methods
    
    	Previously, Method#super_method looked at the called_id to
    	determine the method id to use, but that isn't correct for
    	aliased methods, because the super target depends on the
    	original method id, not the called_id.
    
    	Additionally, aliases can reference methods defined in other
    	classes and modules, and super lookup needs to start in the
    	super of the defined class in such cases.
    
    	This adds tests for Method#super_method for both types of
    	aliases, one that uses VM_METHOD_TYPE_ALIAS and another that
    	does not.  Both check that the results for calling super
    	methods return the expected values.
    
    	To find the defined class for alias methods, add an rb_ prefix
    	to find_defined_class_by_owner in vm_insnhelper.c and make it
    	non-static, so that it can be called from method_super_method
    	in proc.c.
    
    	This bug was original discovered while researching [Bug #11189].
    
    	Fixes [Bug #17130]
    	---
    	 proc.c                   | 13 ++++++--
    	 test/ruby/test_method.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
    	 vm_insnhelper.c          |  6 ++--
    	 3 files changed, 94 insertions(+), 5 deletions(-)
    c98aa2db
    merge revision(s) c60aaed1: [Backport #17130]
    nagachika authored
    	Fix Method#super_method for aliased methods
    
    	Previously, Method#super_method looked at the called_id to
    	determine the method id to use, but that isn't correct for
    	aliased methods, because the super target depends on the
    	original method id, not the called_id.
    
    	Additionally, aliases can reference methods defined in other
    	classes and modules, and super lookup needs to start in the
    	super of the defined class in such cases.
    
    	This adds tests for Method#super_method for both types of
    	aliases, one that uses VM_METHOD_TYPE_ALIAS and another that
    	does not.  Both check that the results for calling super
    	methods return the expected values.
    
    	To find the defined class for alias methods, add an rb_ prefix
    	to find_defined_class_by_owner in vm_insnhelper.c and make it
    	non-static, so that it can be called from method_super_method
    	in proc.c.
    
    	This bug was original discovered while researching [Bug #11189].
    
    	Fixes [Bug #17130]
    	---
    	 proc.c                   | 13 ++++++--
    	 test/ruby/test_method.rb | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
    	 vm_insnhelper.c          |  6 ++--
    	 3 files changed, 94 insertions(+), 5 deletions(-)
Loading