Skip to content

Commit 6c7e8b0

Browse files
committed
Autocorrect and replace #equal? with Primitive.object_equal
1 parent 09a1e60 commit 6c7e8b0

22 files changed

+44
-44
lines changed

src/main/ruby/truffleruby/core/argf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ARGFClass
5959
# @see #advance!
6060
#
6161
def initialize(argv = ARGV, *others)
62-
@argv = argv.equal?(ARGV) ? ARGV : [argv, *others]
62+
@argv = Primitive.object_equal(argv, ARGV) ? ARGV : [argv, *others]
6363
@lineno = 0
6464
# Setting $. sets ARGF.last_lineno, but does not set
6565
# ARGF.lineno, Almost every operation that sets lineno also sets

src/main/ruby/truffleruby/core/array.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def -(other)
8484

8585
def <=>(other)
8686
other = Truffle::Type.rb_check_convert_type other, Array, :to_ary
87-
return 0 if equal? other
87+
return 0 if Primitive.object_equal(self, other)
8888
return nil if Primitive.nil? other
8989

9090
total = other.size
@@ -125,7 +125,7 @@ def ==(other)
125125
return result
126126
end
127127

128-
return true if equal?(other)
128+
return true if Primitive.object_equal(self, other)
129129
unless Primitive.object_kind_of?(other, Array)
130130
return false unless other.respond_to? :to_ary
131131
return other == self
@@ -323,7 +323,7 @@ def cycle(n = nil)
323323

324324
return nil if empty?
325325

326-
if nil.equal? n
326+
if Primitive.object_equal(nil, n)
327327
until empty?
328328
each { |x| yield x }
329329
end
@@ -380,7 +380,7 @@ def eql?(other)
380380
return result
381381
end
382382

383-
return true if equal? other
383+
return true if Primitive.object_equal(self, other)
384384
return false unless Primitive.object_kind_of?(other, Array)
385385
return false if size != other.size
386386

src/main/ruby/truffleruby/core/comparable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
module Comparable
3030
def ==(other)
31-
return true if equal?(other)
31+
return true if Primitive.object_equal(self, other)
3232

3333
return false if Truffle::ThreadOperations.detect_pair_recursion(self, other) do
3434
unless comp = (self <=> other)

src/main/ruby/truffleruby/core/complex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def rationalize(eps = nil)
268268
def to_s
269269
result = real.to_s
270270

271-
if imag < 0 || imag.equal?(-0.0)
271+
if imag < 0 || Primitive.object_equal(imag, -0.0)
272272
result << '-'
273273
else
274274
result << '+'

src/main/ruby/truffleruby/core/env.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def rehash
243243
end
244244

245245
def replace(other)
246-
return self if equal?(other)
246+
return self if Primitive.object_equal(self, other)
247247
other = Truffle::Type.rb_convert_type(other, Hash, :to_hash)
248248
keys_to_delete = keys
249249
other.each do |k, v|
@@ -295,7 +295,7 @@ def to_h
295295
end
296296

297297
def update(other)
298-
return self if equal?(other)
298+
return self if Primitive.object_equal(self, other)
299299
other = Truffle::Type.rb_convert_type(other, Hash, :to_hash)
300300
if block_given?
301301
other.each do |k, v|

src/main/ruby/truffleruby/core/exception.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def exception(message = nil)
9999
def self.to_tty?
100100
# Whether $stderr refers to the original STDERR and STDERR is a tty.
101101
# When using polyglot stdio, we cannot know and assume false.
102-
$stderr.equal?(STDERR) && !STDERR.closed? &&
102+
Primitive.object_equal($stderr, STDERR) && !STDERR.closed? &&
103103
(!Truffle::Boot.get_option('polyglot-stdio') && STDERR.tty?)
104104
end
105105
end
@@ -282,7 +282,7 @@ def self.new(*args)
282282
#
283283
# Otherwise it's called on a Errno subclass and just helps setup
284284
# a instance of the subclass
285-
if self.equal? SystemCallError
285+
if Primitive.object_equal(self, SystemCallError)
286286
case args.size
287287
when 1
288288
if Primitive.object_kind_of?(args.first, Integer)
@@ -326,7 +326,7 @@ def self.new(*args)
326326

327327
if defined?(self::Errno) && Primitive.object_kind_of?(self::Errno, Integer)
328328
error = SystemCallError.errno_error(self, message, self::Errno, location)
329-
if error && Primitive.object_class(error).equal?(self)
329+
if error && Primitive.object_equal(Primitive.object_class(error), self)
330330
return error
331331
end
332332
end

src/main/ruby/truffleruby/core/float.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def to_r
120120
def arg
121121
if nan?
122122
self
123-
elsif self < 0 || equal?(-0.0)
123+
elsif self < 0 || Primitive.object_equal(self, -0.0)
124124
Math::PI
125125
else
126126
0

src/main/ruby/truffleruby/core/hash.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def self.contains_all_internal(one, two)
4141
one.all? do |key, value|
4242
if two.has_key?(key)
4343
two_value = two[key]
44-
value.equal?(two_value) || value == two_value
44+
Primitive.object_equal(value, two_value) || value == two_value
4545
else
4646
false
4747
end
@@ -130,7 +130,7 @@ def eql?(other)
130130
end
131131

132132
def eql_op(op, other)
133-
return true if self.equal? other
133+
return true if Primitive.object_equal(self, other)
134134
unless Primitive.object_kind_of?(other, Hash)
135135
return false unless other.respond_to? :to_hash
136136
return other.send(op, self)

src/main/ruby/truffleruby/core/io.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def self.read_encode(io, str)
487487
internal = io.internal_encoding
488488
external = io.external_encoding || Encoding.default_external
489489

490-
if external.equal? Encoding::BINARY
490+
if Primitive.object_equal(external, Encoding::BINARY)
491491
str.force_encoding external
492492
elsif internal and external
493493
ec = Encoding::Converter.new external, internal

src/main/ruby/truffleruby/core/kernel.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def Complex(real, imag = undefined, exception: true)
5454
module_function :Complex
5555

5656
def Float(obj, exception: true)
57-
raise_exception = !exception.equal?(false)
57+
raise_exception = !Primitive.object_equal(exception, false)
5858
obj = Truffle::Interop.unbox_if_needed(obj)
5959

6060
case obj
@@ -74,7 +74,7 @@ def Float(obj, exception: true)
7474
nil
7575
end
7676
when Complex
77-
if obj.respond_to?(:imag) && obj.imag.equal?(0)
77+
if obj.respond_to?(:imag) && Primitive.object_equal(obj.imag, 0)
7878
Truffle::Type.coerce_to obj, Float, :to_f
7979
else
8080
raise RangeError, "can't convert #{obj} into Float"
@@ -90,7 +90,7 @@ def Float(obj, exception: true)
9090
module_function :Float
9191

9292
def Hash(obj)
93-
return {} if obj.equal?(nil) || obj == []
93+
return {} if Primitive.object_equal(obj, nil) || obj == []
9494

9595
if hash = Truffle::Type.rb_check_convert_type(obj, Hash, :to_hash)
9696
return hash
@@ -104,7 +104,7 @@ def Integer(obj, base = 0, exception: true)
104104
obj = Truffle::Interop.unbox_if_needed(obj)
105105
converted_base = Truffle::Type.rb_check_to_integer(base, :to_int)
106106
base = Primitive.nil?(converted_base) ? 0 : converted_base
107-
raise_exception = !exception.equal?(false)
107+
raise_exception = !Primitive.object_equal(exception, false)
108108

109109
if Primitive.object_kind_of?(obj, String)
110110
Primitive.string_to_inum(obj, base, true, raise_exception)
@@ -203,8 +203,8 @@ def abort(msg = nil)
203203

204204
def autoload(name, file)
205205
nesting = Primitive.caller_nesting
206-
mod = nesting.first || (Kernel.equal?(self) ? Kernel : Object)
207-
if mod.equal?(self)
206+
mod = nesting.first || (Primitive.object_equal(Kernel, self) ? Kernel : Object)
207+
if Primitive.object_equal(mod, self)
208208
super(name, file) # Avoid recursion
209209
else
210210
mod.autoload(name, file)
@@ -213,7 +213,7 @@ def autoload(name, file)
213213
module_function :autoload
214214

215215
def autoload?(name)
216-
if Kernel.equal?(self)
216+
if Primitive.object_equal(Kernel, self)
217217
super(name) # Avoid recursion
218218
else
219219
Object.autoload?(name)

0 commit comments

Comments
 (0)