Skip to content

Commit 09a1e60

Browse files
committed
Autocorrect and replace #class with Primitive.object_class
1 parent 600f466 commit 09a1e60

31 files changed

+79
-79
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def flatten!(level = -1)
507507
level = Primitive.rb_num2int level
508508
return nil if level == 0
509509

510-
out = self.class.allocate # new_reserved size
510+
out = Primitive.object_class(self).allocate # new_reserved size
511511
if Primitive.array_flatten_helper(self, out, level)
512512
Primitive.steal_array_storage(self, out)
513513
return self
@@ -1283,7 +1283,7 @@ def to_h
12831283
each_with_index do |elem, i|
12841284
elem = yield(elem) if block_given?
12851285
unless elem.respond_to?(:to_ary)
1286-
raise TypeError, "wrong element type #{elem.class} at #{i} (expected array)"
1286+
raise TypeError, "wrong element type #{Primitive.object_class(elem)} at #{i} (expected array)"
12871287
end
12881288

12891289
ary = elem.to_ary
@@ -1362,7 +1362,7 @@ def zip(*others)
13621362
elsif Primitive.object_respond_to?(other, :each, false)
13631363
other.to_enum(:each)
13641364
else
1365-
raise TypeError, "wrong argument type #{other.class} (must respond to :each)"
1365+
raise TypeError, "wrong argument type #{Primitive.object_class(other)} (must respond to :each)"
13661366
end
13671367
end
13681368

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def between?(min, max)
8282
def clamp(min, max = undefined)
8383
if Primitive.undefined?(max)
8484
range = min
85-
raise TypeError, "wrong argument type #{range.class} (expected Range)" unless Primitive.object_kind_of?(range, Range)
85+
raise TypeError, "wrong argument type #{Primitive.object_class(range)} (expected Range)" unless Primitive.object_kind_of?(range, Range)
8686
raise ArgumentError, 'cannot clamp with an exclusive range' if range.exclude_end?
8787
min, max = range.begin, range.end
8888
end

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ def ==(other)
199199

200200
def eql?(other)
201201
Primitive.object_kind_of?(other, Complex) and
202-
imag.class == other.imag.class and
203-
real.class == other.real.class and
202+
Primitive.object_class(imag) == Primitive.object_class(other.imag) and
203+
Primitive.object_class(real) == Primitive.object_class(other.real) and
204204
self == other
205205
end
206206

@@ -210,7 +210,7 @@ def coerce(other)
210210
elsif Primitive.object_kind_of?(other, Complex)
211211
[other, self]
212212
else
213-
raise TypeError, "#{other.class} can't be coerced into Complex"
213+
raise TypeError, "#{Primitive.object_class(other)} can't be coerced into Complex"
214214
end
215215
end
216216

@@ -305,7 +305,7 @@ def inspect
305305
end
306306

307307
def fdiv(other)
308-
raise TypeError, "#{other.class} can't be coerced into Complex" unless Primitive.object_kind_of?(other, Numeric)
308+
raise TypeError, "#{Primitive.object_class(other)} can't be coerced into Complex" unless Primitive.object_kind_of?(other, Numeric)
309309

310310
# FIXME
311311
self / other

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def each_child
141141
end
142142

143143
def inspect
144-
"#<#{self.class}:#{@path}>"
144+
"#<#{Primitive.object_class(self)}:#{@path}>"
145145
end
146146

147147
class << self

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def to_h(*arg)
319319
each_with_index(*arg) do |elem, i|
320320
elem = yield(elem) if block_given?
321321
unless elem.respond_to?(:to_ary)
322-
raise TypeError, "wrong element type #{elem.class} at #{i} (expected array)"
322+
raise TypeError, "wrong element type #{Primitive.object_class(elem)} at #{i} (expected array)"
323323
end
324324

325325
ary = elem.to_ary
@@ -342,7 +342,7 @@ def zip(*enums)
342342
elsif Primitive.object_respond_to?(enum, :each, false)
343343
enum.to_enum(:each)
344344
else
345-
raise TypeError, "wrong argument type #{enum.class} (must respond to :each)"
345+
raise TypeError, "wrong argument type #{Primitive.object_class(enum)} (must respond to :each)"
346346
end
347347
end
348348

@@ -798,7 +798,7 @@ def min_max(relative)
798798
else
799799
comp = block_given? ? yield(o, chosen) : o <=> chosen
800800
unless comp
801-
raise ArgumentError, "comparison of #{o.class} with #{chosen} failed"
801+
raise ArgumentError, "comparison of #{Primitive.object_class(o)} with #{chosen} failed"
802802
end
803803

804804
if (Comparable.compare_int(comp) <=> 0) == relative

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ class Enumerator
7070
end
7171

7272
def inspect
73-
return "#<#{self.class}: uninitialized>" if Primitive.nil?(@object) && Primitive.nil?(@iter)
73+
return "#<#{Primitive.object_class(self)}: uninitialized>" if Primitive.nil?(@object) && Primitive.nil?(@iter)
7474

7575
args = @kwargs.empty? ? @args : [*@args, @kwargs]
7676
args = args.empty? ? '' : "(#{args.map(&:inspect).join(', ')})"
77-
"#<#{self.class}: #{@object.inspect}:#{@iter}#{args}>"
77+
"#<#{Primitive.object_class(self)}: #{@object.inspect}:#{@iter}#{args}>"
7878
end
7979

8080
def each(*args, **kwargs, &block)
@@ -538,7 +538,7 @@ def zip(*lists)
538538
elsif Primitive.object_respond_to?(list, :each, false)
539539
list.to_enum :each
540540
else
541-
raise TypeError, "wrong argument type #{list.class} (must respond to :each)"
541+
raise TypeError, "wrong argument type #{Primitive.object_class(list)} (must respond to :each)"
542542
end
543543
end
544544

@@ -795,8 +795,8 @@ def rewind
795795
end
796796

797797
def inspect
798-
return "#<#{self.class.name}: ...>" if Truffle::ThreadOperations.detect_recursion(self) do
799-
return "#<#{self.class.name}: #{@enums || "uninitialized"}>"
798+
return "#<#{Primitive.object_class(self).name}: ...>" if Truffle::ThreadOperations.detect_recursion(self) do
799+
return "#<#{Primitive.object_class(self).name}: #{@enums || "uninitialized"}>"
800800
end
801801
end
802802
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def to_h
281281
each_pair do |*elem|
282282
elem = yield(elem)
283283
unless elem.respond_to?(:to_ary)
284-
raise TypeError, "wrong element type #{elem.class} (expected array)"
284+
raise TypeError, "wrong element type #{Primitive.object_class(elem)} (expected array)"
285285
end
286286

287287
ary = elem.to_ary

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def message
4747

4848
def to_s
4949
msg = Truffle::ExceptionOperations.compute_message(self)
50-
return self.class.to_s if Primitive.nil?(msg)
50+
return Primitive.object_class(self).to_s if Primitive.nil?(msg)
5151
msg
5252
end
5353

@@ -71,9 +71,9 @@ def set_backtrace(bt)
7171
def inspect
7272
s = self.to_s
7373
if s.empty?
74-
self.class.name
74+
Primitive.object_class(self).name
7575
else
76-
"#<#{self.class.name}: #{s}>"
76+
"#<#{Primitive.object_class(self).name}: #{s}>"
7777
end
7878
end
7979

@@ -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 && error.class.equal?(self)
329+
if error && Primitive.object_class(error).equal?(self)
330330
return error
331331
end
332332
end
@@ -377,7 +377,7 @@ def initialize(sig, message = undefined)
377377
sig = sig.to_s
378378
else
379379
sig_converted = Truffle::Type.rb_check_convert_type sig, String, :to_str
380-
raise ArgumentError, "bad signal type #{sig.class.name}" if Primitive.nil? sig_converted
380+
raise ArgumentError, "bad signal type #{Primitive.object_class(sig).name}" if Primitive.nil? sig_converted
381381
sig = sig_converted
382382
end
383383
signal_name = sig

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ def truncate(length)
12281228
end
12291229

12301230
def inspect
1231-
return_string = "#<#{self.class}:0x#{object_id.to_s(16)} path=#{@path}"
1231+
return_string = "#<#{Primitive.object_class(self)}:0x#{object_id.to_s(16)} path=#{@path}"
12321232
return_string << ' (closed)' if closed?
12331233
return_string << '>'
12341234
end

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def self.ruby2_keywords_hash(hash)
112112
def <(other)
113113
other = Truffle::Type.coerce_to(other, Hash, :to_hash)
114114
return false if self.size >= other.size
115-
self.class.contains_all_internal(self, other)
115+
Primitive.object_class(self).contains_all_internal(self, other)
116116
end
117117

118118
def <=(other)
119119
other = Truffle::Type.coerce_to(other, Hash, :to_hash)
120120
return false if self.size > other.size
121-
self.class.contains_all_internal(self, other)
121+
Primitive.object_class(self).contains_all_internal(self, other)
122122
end
123123

124124
def ==(other)
@@ -159,13 +159,13 @@ def eql_op(op, other)
159159
def >(other)
160160
other = Truffle::Type.coerce_to(other, Hash, :to_hash)
161161
return false if self.size <= other.size
162-
self.class.contains_all_internal(other, self)
162+
Primitive.object_class(self).contains_all_internal(other, self)
163163
end
164164

165165
def >=(other)
166166
other = Truffle::Type.coerce_to(other, Hash, :to_hash)
167167
return false if self.size < other.size
168-
self.class.contains_all_internal(other, self)
168+
Primitive.object_class(self).contains_all_internal(other, self)
169169
end
170170

171171
def assoc(key)

0 commit comments

Comments
 (0)