<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_refinement.rb, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) 1e7cf7b2bc1f9b356b2e980e1e18548618da6363: [Backport #21446]</title>
<updated>2026-03-24T05:49:12+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2026-03-24T05:13:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c675ec66e912b3000e05d65bba473e8bf6e18c96'/>
<id>c675ec66e912b3000e05d65bba473e8bf6e18c96</id>
<content type='text'>
	[PATCH] Fix refinement modification of method visibility in superclass

	Previously, this didn't work correctly, resulting in a
	SystemStackError. This fixes the issue by finding the related
	superclass method entry, and updating the orig_me in the
	refinement method to point to the superclass method.

	Fixes [Bug #21446]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] Fix refinement modification of method visibility in superclass

	Previously, this didn't work correctly, resulting in a
	SystemStackError. This fixes the issue by finding the related
	superclass method entry, and updating the orig_me in the
	refinement method to point to the superclass method.

	Fixes [Bug #21446]
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) a4dff09be79b52288a47658964d25e5aa84fc960: [Backport #21673]</title>
<updated>2025-11-29T03:28:14+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-11-29T03:28:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=62135b9da4872b370d6fb579fc4a415e8f641c7d'/>
<id>62135b9da4872b370d6fb579fc4a415e8f641c7d</id>
<content type='text'>
	[PATCH] [Bug #21673] Fix resolving refined module-defined method

	A method defined in a module has no `defined_class`, use the ICLASS
	for it as the `defined_class`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] [Bug #21673] Fix resolving refined module-defined method

	A method defined in a module has no `defined_class`, use the ICLASS
	for it as the `defined_class`.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 18ee7c9a108bf3424814565377c8796e5e455cf7,4a6384ed9358e8fb8464f6e37efb5477182f01db: [Backport #20246] (#10309)</title>
<updated>2024-03-21T00:10:44+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-21T00:10:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=05787897f69087abdabee926971cdf364bd73730'/>
<id>05787897f69087abdabee926971cdf364bd73730</id>
<content type='text'>
Clear all refined CCs on reopening refinement mod

	In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline
	caches for refinements. However, we weren't clearing inline caches when
	defined on a reopened refinement module.

	Fixes [Bug #20246]

	Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clear all refined CCs on reopening refinement mod

	In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline
	caches for refinements. However, we weren't clearing inline caches when
	defined on a reopened refinement module.

	Fixes [Bug #20246]

	Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)</pre>
</div>
</content>
</entry>
<entry>
<title>Fix cache incoherency for ME resolved through VM_METHOD_TYPE_REFINED</title>
<updated>2023-11-28T18:03:04+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2023-11-28T00:19:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cd4207869ff831c41db3ec873b175369ffca080a'/>
<id>cd4207869ff831c41db3ec873b175369ffca080a</id>
<content type='text'>
Previously, we didn't invalidate the method entry wrapped by
VM_METHOD_TYPE_REFINED method entries which could cause calls to
land in the wrong method like it did in the included test.

Do the invalidation, and adjust rb_method_entry_clone() to accommodate
this new invalidation vector.

Fix: cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732
See-also: e201b81f79828c30500947fe8c8ea3c515e3d112
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, we didn't invalidate the method entry wrapped by
VM_METHOD_TYPE_REFINED method entries which could cause calls to
land in the wrong method like it did in the included test.

Do the invalidation, and adjust rb_method_entry_clone() to accommodate
this new invalidation vector.

Fix: cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732
See-also: e201b81f79828c30500947fe8c8ea3c515e3d112
</pre>
</div>
</content>
</entry>
<entry>
<title>Supress warnings by Refinement#refined_class in test code</title>
<updated>2023-08-01T00:48:47+00:00</updated>
<author>
<name>Shugo Maeda</name>
<email>shugo@ruby-lang.org</email>
</author>
<published>2023-08-01T00:48:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0b8045c9c9b9f9c3e22e38f7d77b273efb2db2b0'/>
<id>0b8045c9c9b9f9c3e22e38f7d77b273efb2db2b0</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Refinement#target and deprecate Refinement#refined_class</title>
<updated>2023-07-31T08:23:17+00:00</updated>
<author>
<name>Shugo Maeda</name>
<email>shugo@ruby-lang.org</email>
</author>
<published>2023-07-14T06:13:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a542512b7c394847a488e9b94d9defebe26003ce'/>
<id>a542512b7c394847a488e9b94d9defebe26003ce</id>
<content type='text'>
[Feature #19714]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Feature #19714]
</pre>
</div>
</content>
</entry>
<entry>
<title>use inline cache for refinements</title>
<updated>2023-07-31T08:13:43+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-07-31T07:17:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732'/>
<id>cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732</id>
<content type='text'>
From Ruby 3.0, refined method invocations are slow because
resolved methods are not cached by inline cache because of
conservertive strategy. However, `using` clears all caches
so that it seems safe to cache resolved method entries.

This patch caches resolved method entries in inline cache
and clear all of inline method caches when `using` is called.

fix [Bug #18572]

```ruby
 # without refinements

class C
  def foo = :C
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}

_END__
              user     system      total        real
master    0.362859   0.002544   0.365403 (  0.365424)
modified  0.357251   0.000000   0.357251 (  0.357258)
```

```ruby
 # with refinment but without using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
__END__
               user     system      total        real
master     0.957182   0.000000   0.957182 (  0.957212)
modified   0.359228   0.000000   0.359228 (  0.359238)
```

```ruby
 # with using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

using R

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
From Ruby 3.0, refined method invocations are slow because
resolved methods are not cached by inline cache because of
conservertive strategy. However, `using` clears all caches
so that it seems safe to cache resolved method entries.

This patch caches resolved method entries in inline cache
and clear all of inline method caches when `using` is called.

fix [Bug #18572]

```ruby
 # without refinements

class C
  def foo = :C
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}

_END__
              user     system      total        real
master    0.362859   0.002544   0.365403 (  0.365424)
modified  0.357251   0.000000   0.357251 (  0.357258)
```

```ruby
 # with refinment but without using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
__END__
               user     system      total        real
master     0.957182   0.000000   0.957182 (  0.957212)
modified   0.359228   0.000000   0.359228 (  0.359238)
```

```ruby
 # with using

class C
  def foo = :C
end

module R
  refine C do
    def foo = :R
  end
end

N = 1_000_000

using R

obj = C.new
require 'benchmark'
Benchmark.bm{|x|
  x.report{N.times{
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
    obj.foo; obj.foo; obj.foo; obj.foo; obj.foo;
  }}
}
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow calling protected methods from refinements</title>
<updated>2022-06-16T20:24:48+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2022-05-27T20:47:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ae163cae6b3f01e0fb827e0a18d5889f9703617f'/>
<id>ae163cae6b3f01e0fb827e0a18d5889f9703617f</id>
<content type='text'>
Previously protected methods on refinements could never be called
because they were seen as being "defined" on the hidden refinement
ICLASS.

This commit updates calling refined protected methods so that they are
considered to be defined on the original class (the one being refined).

This ended up using the same behaviour that was used to check whether a
call to super was allowed, so I extracted that into a method.

[Bug #18806]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously protected methods on refinements could never be called
because they were seen as being "defined" on the hidden refinement
ICLASS.

This commit updates calling refined protected methods so that they are
considered to be defined on the original class (the one being refined).

This ended up using the same behaviour that was used to check whether a
call to super was allowed, so I extracted that into a method.

[Bug #18806]
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove Refinement#{extend_object,append_features,prepend_features}</title>
<updated>2022-01-05T18:59:03+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-12-27T19:38:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=791343b5bb1b8bb11de4ba2800118c20e36b5a71'/>
<id>791343b5bb1b8bb11de4ba2800118c20e36b5a71</id>
<content type='text'>
Also make include, prepend, and extend raise a TypeError if one
of the modules is a refinement.

Implements [Feature #18270]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also make include, prepend, and extend raise a TypeError if one
of the modules is a refinement.

Implements [Feature #18270]
</pre>
</div>
</content>
</entry>
<entry>
<title>test/ruby/test_refinement.rb: Remove "assigned but unused variable"</title>
<updated>2022-01-05T14:46:27+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2022-01-05T14:46:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f22296d27e9be616a16f9befd2f7c9c2d2f972c3'/>
<id>f22296d27e9be616a16f9befd2f7c9c2d2f972c3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
