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

ruby-changes:47497

From: nobu <ko1@a...>
Date: Thu, 17 Aug 2017 23:58:16 +0900 (JST)
Subject: [ruby-changes:47497] nobu:r59613 (trunk): vm_method.c: alias warning at refined method

nobu	2017-08-17 23:58:11 +0900 (Thu, 17 Aug 2017)

  New Revision: 59613

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59613

  Log:
    vm_method.c: alias warning at refined method
    
    * vm_method.c (rb_method_entry_make): suppress a warning at
      refined method which will not be redefined.
      [ruby-core:82385] [Bug #13817]

  Modified files:
    trunk/test/ruby/test_refinement.rb
    trunk/vm_method.c
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 59612)
+++ vm_method.c	(revision 59613)
@@ -541,6 +541,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L541
 	if (RTEST(ruby_verbose) &&
 	    type != VM_METHOD_TYPE_UNDEF &&
 	    (old_def->alias_count == 0) &&
+	    !make_refined &&
 	    old_def->type != VM_METHOD_TYPE_UNDEF &&
 	    old_def->type != VM_METHOD_TYPE_ZSUPER &&
 	    old_def->type != VM_METHOD_TYPE_ALIAS) {
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 59612)
+++ test/ruby/test_refinement.rb	(revision 59613)
@@ -1944,6 +1944,23 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1944
     end
   end
 
+  def test_refined_method_alias_warning
+    c = Class.new do
+      def t; :t end
+      def f; :f end
+    end
+    Module.new do
+      refine(c) do
+        alias foo t
+      end
+    end
+    assert_warning('', '[ruby-core:82385] [Bug #13817] refined method is not redefined') do
+      c.class_eval do
+        alias foo f
+      end
+    end
+  end
+
   private
 
   def eval_using(mod, s)

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

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