mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Test CC invalidation for singleton classes of objects (#15360)
I made a recent change where all the tests passed but it turns out it was still wrong. We didn't have any tests for CC invalidation on singletons of objects that aren't classes or modules.
This commit is contained in:
parent
f92001344d
commit
a8b49ab487
Notes:
git
2025-12-01 21:51:56 +00:00
Merged-By: luke-gru <luke.gru@gmail.com>
@ -887,4 +887,34 @@ CODE
|
||||
class C; end
|
||||
end;
|
||||
end
|
||||
|
||||
def test_singleton_cc_invalidation
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}")
|
||||
begin;
|
||||
class T
|
||||
def hi
|
||||
"hi"
|
||||
end
|
||||
end
|
||||
|
||||
t = T.new
|
||||
t.singleton_class
|
||||
|
||||
def hello(t)
|
||||
t.hi
|
||||
end
|
||||
|
||||
5.times do
|
||||
hello(t) # populate inline cache on `t.singleton_class`.
|
||||
end
|
||||
|
||||
class T
|
||||
remove_method :hi # invalidate `t.singleton_class` ccs for `hi`
|
||||
end
|
||||
|
||||
assert_raise NoMethodError do
|
||||
hello(t)
|
||||
end
|
||||
end;
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user