Skip to content

Commit 867d444

Browse files
committed
Remove Truffle::Type.check_convert_type
* Always use the more correct rb_check_convert_type instead.
1 parent 9f0ba56 commit 867d444

File tree

11 files changed

+25
-46
lines changed

11 files changed

+25
-46
lines changed

lib/truffle/stringio.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def yaml_initialize(type, val)
679679

680680
unless sep == $/ or sep.nil?
681681
osep = sep
682-
sep = Truffle::Type.check_convert_type sep, String, :to_str
682+
sep = Truffle::Type.rb_check_convert_type sep, String, :to_str
683683
limit = Truffle::Type.coerce_to_int osep unless sep
684684
end
685685
end

src/main/ruby/core/array.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def -(other)
8383
end
8484

8585
def <=>(other)
86-
other = Truffle::Type.check_convert_type other, Array, :to_ary
86+
other = Truffle::Type.rb_check_convert_type other, Array, :to_ary
8787
return 0 if equal? other
8888
return nil if other.nil?
8989

@@ -109,7 +109,7 @@ def <=>(other)
109109

110110
def *(count)
111111
Truffle.primitive :array_mul
112-
if str = Truffle::Type.check_convert_type(count, String, :to_str)
112+
if str = Truffle::Type.rb_check_convert_type(count, String, :to_str)
113113
join(str)
114114
else
115115
self * Truffle::Type.coerce_to(count, Integer, :to_int)
@@ -1002,7 +1002,7 @@ def sample(count=undefined, options=undefined)
10021002
return at Kernel.rand(size) if undefined.equal? count
10031003

10041004
if undefined.equal? options
1005-
if o = Truffle::Type.check_convert_type(count, Hash, :to_hash)
1005+
if o = Truffle::Type.rb_check_convert_type(count, Hash, :to_hash)
10061006
options = o
10071007
count = nil
10081008
else

src/main/ruby/core/enumerator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def collect_concat
455455
yielder.yield v
456456
end
457457
else
458-
array = Truffle::Type.check_convert_type yield_ret, Array, :to_ary
458+
array = Truffle::Type.rb_check_convert_type yield_ret, Array, :to_ary
459459
if array
460460
array.each do |v|
461461
yielder.yield v
@@ -472,7 +472,7 @@ def zip(*lists)
472472
return super(*lists) { |entry| yield entry } if block_given?
473473

474474
lists.map! do |list|
475-
array = Truffle::Type.check_convert_type list, Array, :to_ary
475+
array = Truffle::Type.rb_check_convert_type list, Array, :to_ary
476476

477477
case
478478
when array

src/main/ruby/core/hash.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def self.try_convert(obj)
7070
def self._constructor_fallback(*args)
7171
if args.size == 1
7272
obj = args.first
73-
if hash = Truffle::Type.check_convert_type(obj, Hash, :to_hash)
73+
if hash = Truffle::Type.rb_check_convert_type(obj, Hash, :to_hash)
7474
new_hash = allocate.replace(hash)
7575
new_hash.default = nil
7676
return new_hash
77-
elsif associate_array = Truffle::Type.check_convert_type(obj, Array, :to_ary)
77+
elsif associate_array = Truffle::Type.rb_check_convert_type(obj, Array, :to_ary)
7878
return new_from_associate_array(associate_array)
7979
end
8080
end

src/main/ruby/core/io.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ def lines(*args, &block)
15691569
when nil
15701570
sep = nil
15711571
else
1572-
unless sep = Truffle::Type.check_convert_type(sep_or_limit, String, :to_str)
1572+
unless sep = Truffle::Type.rb_check_convert_type(sep_or_limit, String, :to_str)
15731573
sep = $/
15741574
limit = Truffle::Type.coerce_to sep_or_limit, Integer, :to_int
15751575
end

src/main/ruby/core/kernel.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636

3737
module Kernel
3838
def Array(obj)
39-
ary = Truffle::Type.check_convert_type obj, Array, :to_ary
39+
ary = Truffle::Type.rb_check_convert_type obj, Array, :to_ary
4040

4141
return ary if ary
4242

43-
if array = Truffle::Type.check_convert_type(obj, Array, :to_a)
43+
if array = Truffle::Type.rb_check_convert_type(obj, Array, :to_a)
4444
array
4545
else
4646
[obj]
@@ -82,7 +82,7 @@ def Float(obj)
8282
def Hash(obj)
8383
return {} if obj.equal?(nil) || obj == []
8484

85-
if hash = Truffle::Type.check_convert_type(obj, Hash, :to_hash)
85+
if hash = Truffle::Type.rb_check_convert_type(obj, Hash, :to_hash)
8686
return hash
8787
end
8888

src/main/ruby/core/process.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def self.coerce_rlimit_resource(resource)
665665
when Symbol, String
666666
# do nothing
667667
else
668-
unless r = Truffle::Type.check_convert_type(resource, String, :to_str)
668+
unless r = Truffle::Type.rb_check_convert_type(resource, String, :to_str)
669669
return Truffle::Type.coerce_to resource, Integer, :to_int
670670
end
671671

src/main/ruby/core/regexp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def ===(other)
231231
if other.kind_of? Symbol
232232
other = other.to_s
233233
elsif !other.kind_of? String
234-
other = Truffle::Type.check_convert_type other, String, :to_str
234+
other = Truffle::Type.rb_check_convert_type other, String, :to_str
235235
unless other
236236
Truffle::RegexpOperations.set_last_match(nil, Truffle.invoke_primitive(:caller_binding))
237237
return false

src/main/ruby/core/string.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def subpattern(pattern, capture)
349349

350350
return nil unless match
351351

352-
if index = Truffle::Type.check_convert_type(capture, Integer, :to_int)
352+
if index = Truffle::Type.rb_check_convert_type(capture, Integer, :to_int)
353353
return nil if index >= match.size || -index >= match.size
354354
capture = index
355355
end
@@ -402,7 +402,7 @@ def encode!(to=undefined, from=undefined, options=undefined)
402402
options = to
403403
to_enc = Encoding.default_internal
404404
else
405-
opts = Truffle::Type.check_convert_type to, Hash, :to_hash
405+
opts = Truffle::Type.rb_check_convert_type to, Hash, :to_hash
406406

407407
if opts
408408
options = opts
@@ -421,7 +421,7 @@ def encode!(to=undefined, from=undefined, options=undefined)
421421
options = from
422422
from_enc = encoding
423423
else
424-
opts = Truffle::Type.check_convert_type from, Hash, :to_hash
424+
opts = Truffle::Type.rb_check_convert_type from, Hash, :to_hash
425425

426426
if opts
427427
options = opts
@@ -497,7 +497,7 @@ def encode(to=undefined, from=undefined, options=undefined)
497497

498498
def end_with?(*suffixes)
499499
suffixes.each do |original_suffix|
500-
suffix = Truffle::Type.check_convert_type original_suffix, String, :to_str
500+
suffix = Truffle::Type.rb_check_convert_type original_suffix, String, :to_str
501501
unless suffix
502502
raise TypeError, "no implicit conversion of #{original_suffix.class} into String"
503503
end
@@ -716,7 +716,7 @@ def sub!(pattern, replacement=undefined, &block)
716716
untrusted = replacement.untrusted?
717717

718718
unless replacement.kind_of?(String)
719-
hash = Truffle::Type.check_convert_type(replacement, Hash, :to_hash)
719+
hash = Truffle::Type.rb_check_convert_type(replacement, Hash, :to_hash)
720720
replacement = StringValue(replacement) unless hash
721721
tainted ||= replacement.tainted?
722722
untrusted ||= replacement.untrusted?
@@ -1466,7 +1466,7 @@ def rindex(sub, finish=undefined)
14661466

14671467
def start_with?(*prefixes)
14681468
prefixes.each do |original_prefix|
1469-
prefix = Truffle::Type.check_convert_type original_prefix, String, :to_str
1469+
prefix = Truffle::Type.rb_check_convert_type original_prefix, String, :to_str
14701470
unless prefix
14711471
raise TypeError, "no implicit conversion of #{original_prefix.class} into String"
14721472
end
@@ -1505,7 +1505,7 @@ def %(args)
15051505
if args.is_a? Hash
15061506
sprintf(self, args)
15071507
else
1508-
result = Truffle::Type.check_convert_type args, Array, :to_ary
1508+
result = Truffle::Type.rb_check_convert_type args, Array, :to_ary
15091509
if result.nil?
15101510
sprintf(self, args)
15111511
else

src/main/ruby/core/truffle/string_operations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.gsub_internal_block(orig, pattern, &block)
3131

3232
def self.gsub_internal(orig, pattern, replacement)
3333
unless replacement.kind_of?(String)
34-
hash = Truffle::Type.check_convert_type(replacement, Hash, :to_hash)
34+
hash = Truffle::Type.rb_check_convert_type(replacement, Hash, :to_hash)
3535
replacement = StringValue(replacement) unless hash
3636
end
3737

0 commit comments

Comments
 (0)