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:
Luke Gruber 2025-12-01 16:51:29 -05:00 committed by GitHub
parent f92001344d
commit a8b49ab487
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-12-01 21:51:56 +00:00
Merged-By: luke-gru <luke.gru@gmail.com>

View File

@ -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