[前][次][番号順一覧][スレッド一覧]

ruby-changes:63603

From: Alan <ko1@a...>
Date: Sat, 14 Nov 2020 01:46:27 +0900 (JST)
Subject: [ruby-changes:63603] 7826210541 (master): Use rb_attr_get() for hidden ivar

https://git.ruby-lang.org/ruby.git/commit/?id=7826210541

From 782621054178c5518b76cd5a1ee3588daf69854f Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Thu, 12 Nov 2020 13:19:41 -0500
Subject: Use rb_attr_get() for hidden ivar

rb_ivar_get() can issue an uninitialized ivar warning. We never want to
issue warnings about hidden ivars as they are not actionable for users.

diff --git a/class.c b/class.c
index 7cc087f..48450a5 100644
--- a/class.c
+++ b/class.c
@@ -1811,7 +1811,7 @@ singleton_class_of(VALUE obj) https://github.com/ruby/ruby/blob/trunk/class.c#L1811
 
     klass = RBASIC(obj)->klass;
     if (!(FL_TEST(klass, FL_SINGLETON) &&
-	  rb_ivar_get(klass, id_attached) == obj)) {
+          rb_attr_get(klass, id_attached) == obj)) {
 	rb_serial_t serial = RCLASS_SERIAL(klass);
 	klass = rb_make_metaclass(obj, klass);
 	RCLASS_SERIAL(klass) = serial;
@@ -1852,7 +1852,7 @@ rb_singleton_class_get(VALUE obj) https://github.com/ruby/ruby/blob/trunk/class.c#L1852
     }
     klass = RBASIC(obj)->klass;
     if (!FL_TEST(klass, FL_SINGLETON)) return Qnil;
-    if (rb_ivar_get(klass, id_attached) != obj) return Qnil;
+    if (rb_attr_get(klass, id_attached) != obj) return Qnil;
     return klass;
 }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]