From d0a9df227041c4e81432bb4e80f5e5ba776ac6f4 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Mon, 9 Feb 2026 17:36:14 -0500 Subject: [PATCH] Faster `singleton_class_of` --- lib/tapioca/runtime/reflection.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tapioca/runtime/reflection.rb b/lib/tapioca/runtime/reflection.rb index 2c421039f..b32386e9a 100644 --- a/lib/tapioca/runtime/reflection.rb +++ b/lib/tapioca/runtime/reflection.rb @@ -21,7 +21,6 @@ module Reflection CLASS_METHOD = Kernel.instance_method(:class) #: UnboundMethod CONSTANTS_METHOD = Module.instance_method(:constants) #: UnboundMethod NAME_METHOD = Module.instance_method(:name) #: UnboundMethod - SINGLETON_CLASS_METHOD = Object.instance_method(:singleton_class) #: UnboundMethod ANCESTORS_METHOD = Module.instance_method(:ancestors) #: UnboundMethod SUPERCLASS_METHOD = Class.instance_method(:superclass) #: UnboundMethod OBJECT_ID_METHOD = BasicObject.instance_method(:__id__) #: UnboundMethod @@ -66,7 +65,9 @@ def name_of(constant) #: (T::Module[top] constant) -> Class[top] def singleton_class_of(constant) - SINGLETON_CLASS_METHOD.bind_call(constant) + class << constant + self + end end #: (T::Module[top] constant) -> Array[T::Module[top]]