Skip to content

Conversation

@amomchilov
Copy link
Contributor

Motivation

Removes this line noise from CI logs:

/home/runner/work/tapioca/tapioca/spec/tapioca/runtime/reflection_spec.rb:55: warning: redefining '__id__' may cause serious problems

Implementation

Hooks in the Warning callback chain, raises and exception, and ignores it if it's the one we expected.

@amomchilov amomchilov self-assigned this Jan 2, 2026
@amomchilov amomchilov added the enhancement New feature or request label Jan 2, 2026
Comment on lines 99 to 116
it "might return the wrong results without Reflection helpers" do
foo = LyingFoo.new

refute_equal([], LyingFoo.constants)
refute_equal("Tapioca::LyingFoo", LyingFoo.name)
refute_equal([Object, Kernel, BasicObject], LyingFoo.ancestors)
refute_equal(Object, LyingFoo.superclass)
assert_equal(String, LyingFoo.singleton_class)
assert_equal([:foo, :bar, :baz], LyingFoo.public_instance_methods)
assert_equal([:foo, :bar, :baz], LyingFoo.protected_instance_methods)
assert_equal([:foo, :bar, :baz], LyingFoo.private_instance_methods)
assert_equal(:lies, LyingFoo.method(:class))

refute_equal(LyingFoo, foo.class)
assert_equal(1, foo.__id__)
refute(foo.equal?(foo))
assert(foo.equal?(1))
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need this test?

assert_instance_of(Method, method)

assert_equal(LyingFoo, Runtime::Reflection.class_of(foo))
refute_equal(1, Runtime::Reflection.object_id_of(foo))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not override __id__ and just test the id against the real one?

Suggested change
refute_equal(foo.__id__, Runtime::Reflection.object_id_of(foo))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants