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

ruby-changes:59074

From: Yuki <ko1@a...>
Date: Thu, 5 Dec 2019 10:50:39 +0900 (JST)
Subject: [ruby-changes:59074] 18d3b5a93a (master): Do not attempt to call methods on the receiver if it is a basic object

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

From 18d3b5a93a2d52412f8f563d58db682b41d5c98c Mon Sep 17 00:00:00 2001
From: Yuki Nishijima <yk.nishijima@g...>
Date: Wed, 4 Dec 2019 19:55:01 -0500
Subject: Do not attempt to call methods on the receiver if it is a basic
 object


diff --git a/lib/did_you_mean/spell_checkers/method_name_checker.rb b/lib/did_you_mean/spell_checkers/method_name_checker.rb
index 3ca8a37..3a38245 100644
--- a/lib/did_you_mean/spell_checkers/method_name_checker.rb
+++ b/lib/did_you_mean/spell_checkers/method_name_checker.rb
@@ -43,14 +43,22 @@ module DidYouMean https://github.com/ruby/ruby/blob/trunk/lib/did_you_mean/spell_checkers/method_name_checker.rb#L43
     end
 
     def corrections
-      @corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - NAMES_TO_EXCLUDE[@receiver.class]
+      @corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - names_to_exclude
     end
 
     def method_names
-      method_names = receiver.methods + receiver.singleton_methods
-      method_names += receiver.private_methods if @private_call
-      method_names.uniq!
-      method_names
+      if Object === receiver
+        method_names = receiver.methods + receiver.singleton_methods
+        method_names += receiver.private_methods if @private_call
+        method_names.uniq!
+        method_names
+      else
+        []
+      end
+    end
+
+    def names_to_exclude
+      Object === receiver ? NAMES_TO_EXCLUDE[receiver.class] : []
     end
   end
 end
-- 
cgit v0.10.2


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

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