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

ruby-changes:27961

From: nobu <ko1@a...>
Date: Sun, 31 Mar 2013 06:27:54 +0900 (JST)
Subject: [ruby-changes:27961] nobu:r40013 (trunk): class.c: suppress wrong warning

nobu	2013-03-31 06:27:27 +0900 (Sun, 31 Mar 2013)

  New Revision: 40013

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40013

  Log:
    class.c: suppress wrong warning
    
    * class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get
      instance variable to get rid of wrong warning about __attached__.
      [ruby-core:53839] [Bug #8188]

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/test/ruby/test_eval.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40012)
+++ ChangeLog	(revision 40013)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Mar 31 06:27:17 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get
+	  instance variable to get rid of wrong warning about __attached__.
+	  [ruby-core:53839] [Bug #8188]
+
 Sat Mar 30 14:11:28 2013  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* bcc32: removed. agreed at
Index: class.c
===================================================================
--- class.c	(revision 40012)
+++ class.c	(revision 40013)
@@ -307,6 +307,14 @@ rb_singleton_class_attached(VALUE klass, https://github.com/ruby/ruby/blob/trunk/class.c#L307
  */
 #define META_CLASS_OF_CLASS_CLASS_P(k)  (METACLASS_OF(k) == (k))
 
+/*!
+ * whether k has a metaclass
+ * @retval 1 if \a k has a metaclass
+ * @retval 0 otherwise
+ */
+#define HAVE_METACLASS_P(k) \
+    (FL_TEST(METACLASS_OF(k), FL_SINGLETON) && \
+     rb_ivar_get(METACLASS_OF(k), id_attached) == (k))
 
 /*!
  * ensures \a klass belongs to its own eigenclass.
@@ -316,7 +324,7 @@ rb_singleton_class_attached(VALUE klass, https://github.com/ruby/ruby/blob/trunk/class.c#L324
  * @note this macro creates a new eigenclass if necessary.
  */
 #define ENSURE_EIGENCLASS(klass) \
- (rb_ivar_get(METACLASS_OF(klass), id_attached) == (klass) ? METACLASS_OF(klass) : make_metaclass(klass))
+    (HAVE_METACLASS_P(klass) ? METACLASS_OF(klass) : make_metaclass(klass))
 
 
 /*!
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 40012)
+++ test/ruby/test_eval.rb	(revision 40013)
@@ -215,6 +215,13 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L215
     end
   end
 
+  def test_instance_eval_on_argf_singleton_class
+    bug8188 = '[ruby-core:53839] [Bug #8188]'
+    assert_warning('', bug8188) do
+      ARGF.singleton_class.instance_eval{}
+    end
+  end
+
   class Foo
     Bar = 2
   end

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

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