rbs 3.5.3 → 3.6.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/dependabot.yml +5 -1
- data/.github/workflows/ruby.yml +2 -18
- data/.github/workflows/windows.yml +26 -0
- data/.rubocop.yml +28 -1
- data/CHANGELOG.md +58 -0
- data/Rakefile +8 -2
- data/core/array.rbs +10 -10
- data/core/basic_object.rbs +4 -4
- data/core/builtin.rbs +4 -4
- data/core/dir.rbs +1 -1
- data/core/enumerable.rbs +17 -11
- data/core/enumerator/product.rbs +1 -1
- data/core/enumerator.rbs +9 -2
- data/core/errors.rbs +1 -1
- data/core/exception.rbs +1 -1
- data/core/fiber.rbs +1 -1
- data/core/file.rbs +1 -1
- data/core/global_variables.rbs +2 -2
- data/core/integer.rbs +4 -4
- data/core/kernel.rbs +69 -40
- data/core/method.rbs +98 -7
- data/core/module.rbs +3 -3
- data/core/proc.rbs +184 -23
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +1 -1
- data/core/range.rbs +30 -0
- data/core/rbs/unnamed/env_class.rbs +7 -7
- data/core/rbs/unnamed/random.rbs +14 -14
- data/core/refinement.rbs +16 -26
- data/core/regexp.rbs +2 -2
- data/core/symbol.rbs +34 -26
- data/core/thread.rbs +8 -7
- data/core/trace_point.rbs +12 -12
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +26 -12
- data/ext/rbs_extension/lexer.c +1 -1
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexer.re +1 -1
- data/ext/rbs_extension/lexstate.c +16 -0
- data/ext/rbs_extension/location.c +27 -39
- data/ext/rbs_extension/location.h +7 -2
- data/ext/rbs_extension/parser.c +119 -51
- data/ext/rbs_extension/ruby_objs.c +2 -1
- data/ext/rbs_extension/ruby_objs.h +1 -1
- data/lib/rbs/ast/declarations.rb +36 -0
- data/lib/rbs/ast/type_param.rb +71 -15
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +5 -0
- data/lib/rbs/cli/validate.rb +81 -7
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/definition.rb +2 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +30 -4
- data/lib/rbs/definition_builder.rb +21 -6
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +8 -3
- data/lib/rbs/file_finder.rb +9 -12
- data/lib/rbs/location_aux.rb +2 -6
- data/lib/rbs/locator.rb +8 -5
- data/lib/rbs/prototype/rbi.rb +2 -1
- data/lib/rbs/prototype/runtime.rb +3 -2
- data/lib/rbs/sorter.rb +9 -6
- data/lib/rbs/test/type_check.rb +13 -0
- data/lib/rbs/types.rb +11 -0
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/vendorer.rb +3 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -0
- data/sig/declarations.rbs +6 -0
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +3 -1
- data/sig/errors.rbs +3 -2
- data/sig/file_finder.rbs +24 -2
- data/sig/location.rbs +0 -3
- data/sig/method_types.rbs +1 -1
- data/sig/sorter.rbs +1 -1
- data/sig/type_param.rbs +41 -9
- data/sig/types.rbs +12 -0
- data/sig/visitor.rbs +47 -0
- data/stdlib/csv/0/csv.rbs +44 -6
- data/stdlib/digest/0/digest.rbs +22 -28
- data/stdlib/ipaddr/0/ipaddr.rbs +1 -1
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/net-http/0/net-http.rbs +2 -2
- data/stdlib/psych/0/store.rbs +1 -1
- data/stdlib/uri/0/ldap.rbs +1 -1
- data/stdlib/zlib/0/deflate.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +5 -1
- metadata +6 -2
data/core/kernel.rbs
CHANGED
@@ -282,7 +282,7 @@ module Kernel : BasicObject
|
|
282
282
|
# 1.class #=> Integer
|
283
283
|
# self.class #=> Object
|
284
284
|
#
|
285
|
-
def class: () ->
|
285
|
+
def class: () -> Class
|
286
286
|
|
287
287
|
# <!--
|
288
288
|
# rdoc-file=vm_eval.c
|
@@ -675,7 +675,7 @@ module Kernel : BasicObject
|
|
675
675
|
| (int | _ToR rational_like, exception: bool) -> Rational?
|
676
676
|
| (int | _ToR numer, ?int | _ToR denom, ?exception: true) -> Rational
|
677
677
|
| (int | _ToR numer, ?int | _ToR denom, exception: bool) -> Rational?
|
678
|
-
| [T] (Numeric&_RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
|
678
|
+
| [T] (Numeric & _RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
|
679
679
|
| [T < Numeric] (T value, 1, ?exception: bool) -> T
|
680
680
|
| (untyped, ?untyped, ?exception: bool) -> Rational?
|
681
681
|
|
@@ -1319,7 +1319,7 @@ module Kernel : BasicObject
|
|
1319
1319
|
# See also Random.rand.
|
1320
1320
|
#
|
1321
1321
|
def self?.rand: (?0) -> Float
|
1322
|
-
| (int arg0) ->
|
1322
|
+
| (int arg0) -> Integer
|
1323
1323
|
| (::Range[Integer] arg0) -> Integer?
|
1324
1324
|
| (::Range[Float] arg0) -> Float?
|
1325
1325
|
|
@@ -2066,7 +2066,7 @@ module Kernel : BasicObject
|
|
2066
2066
|
# Returns true if two objects do not match (using the *=~* method), otherwise
|
2067
2067
|
# false.
|
2068
2068
|
#
|
2069
|
-
def !~: (untyped) -> bool
|
2069
|
+
def !~: (untyped other) -> bool
|
2070
2070
|
|
2071
2071
|
# <!--
|
2072
2072
|
# rdoc-file=object.c
|
@@ -2086,7 +2086,7 @@ module Kernel : BasicObject
|
|
2086
2086
|
# When you define #<=>, you can include Comparable to gain the methods #<=, #<,
|
2087
2087
|
# #==, #>=, #> and #between?.
|
2088
2088
|
#
|
2089
|
-
def <=>: (untyped) ->
|
2089
|
+
def <=>: (untyped other) -> 0?
|
2090
2090
|
|
2091
2091
|
# <!--
|
2092
2092
|
# rdoc-file=object.c
|
@@ -2096,7 +2096,7 @@ module Kernel : BasicObject
|
|
2096
2096
|
# typically overridden by descendants to provide meaningful semantics in `case`
|
2097
2097
|
# statements.
|
2098
2098
|
#
|
2099
|
-
|
2099
|
+
alias === ==
|
2100
2100
|
|
2101
2101
|
# <!--
|
2102
2102
|
# rdoc-file=kernel.rb
|
@@ -2152,8 +2152,8 @@ module Kernel : BasicObject
|
|
2152
2152
|
# chris.define_singleton_method(:greet) {|greeting| "#{greeting}, I'm Chris!" }
|
2153
2153
|
# chris.greet("Hi") #=> "Hi, I'm Chris!"
|
2154
2154
|
#
|
2155
|
-
def define_singleton_method: (interned, Method | UnboundMethod | Proc method) -> Symbol
|
2156
|
-
| (interned) { (
|
2155
|
+
def define_singleton_method: (interned name, Method | UnboundMethod | Proc method) -> Symbol
|
2156
|
+
| (interned name) { (?) -> untyped } -> Symbol
|
2157
2157
|
|
2158
2158
|
# <!--
|
2159
2159
|
# rdoc-file=io.c
|
@@ -2170,7 +2170,7 @@ module Kernel : BasicObject
|
|
2170
2170
|
#
|
2171
2171
|
# 1cat[4, 5, 6]
|
2172
2172
|
#
|
2173
|
-
def display: (?_Writer port) ->
|
2173
|
+
def display: (?_Writer port) -> nil
|
2174
2174
|
|
2175
2175
|
# <!--
|
2176
2176
|
# rdoc-file=object.c
|
@@ -2210,7 +2210,7 @@ module Kernel : BasicObject
|
|
2210
2210
|
# s3 = s1.dup #=> #<Klass:0x401c1084>
|
2211
2211
|
# s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084>
|
2212
2212
|
#
|
2213
|
-
def dup: () ->
|
2213
|
+
def dup: () -> instance
|
2214
2214
|
|
2215
2215
|
# <!-- rdoc-file=enumerator.c -->
|
2216
2216
|
# Creates a new Enumerator which will enumerate by calling `method` on `obj`,
|
@@ -2267,10 +2267,8 @@ module Kernel : BasicObject
|
|
2267
2267
|
# enum.first(4) # => [1, 1, 1, 2]
|
2268
2268
|
# enum.size # => 42
|
2269
2269
|
#
|
2270
|
-
def enum_for: (
|
2271
|
-
| () ?{ () -> Integer } -> Enumerator[untyped, self]
|
2270
|
+
def enum_for: (?interned method, *untyped, **untyped) ?{ (*untyped, **untyped) -> Integer } -> Enumerator[untyped, untyped]
|
2272
2271
|
|
2273
|
-
%a{annotate:rdoc:skip}
|
2274
2272
|
alias to_enum enum_for
|
2275
2273
|
|
2276
2274
|
# <!--
|
@@ -2308,7 +2306,7 @@ module Kernel : BasicObject
|
|
2308
2306
|
# 1 == 1.0 #=> true
|
2309
2307
|
# 1.eql? 1.0 #=> false
|
2310
2308
|
#
|
2311
|
-
def eql?: (untyped) -> bool
|
2309
|
+
def eql?: (untyped other) -> bool
|
2312
2310
|
|
2313
2311
|
# <!--
|
2314
2312
|
# rdoc-file=eval.c
|
@@ -2333,7 +2331,7 @@ module Kernel : BasicObject
|
|
2333
2331
|
# k.extend(Mod) #=> #<Klass:0x401b3bc8>
|
2334
2332
|
# k.hello #=> "Hello from Mod.\n"
|
2335
2333
|
#
|
2336
|
-
def extend: (Module, *Module) -> self
|
2334
|
+
def extend: (Module module, *Module other_modules) -> self
|
2337
2335
|
|
2338
2336
|
# <!--
|
2339
2337
|
# rdoc-file=object.c
|
@@ -2447,7 +2445,7 @@ module Kernel : BasicObject
|
|
2447
2445
|
# b.instance_of? B #=> true
|
2448
2446
|
# b.instance_of? C #=> false
|
2449
2447
|
#
|
2450
|
-
def instance_of?: (Module) -> bool
|
2448
|
+
def instance_of?: (Module | Class module_or_class) -> bool
|
2451
2449
|
|
2452
2450
|
# <!--
|
2453
2451
|
# rdoc-file=object.c
|
@@ -2467,7 +2465,7 @@ module Kernel : BasicObject
|
|
2467
2465
|
# fred.instance_variable_defined?("@b") #=> true
|
2468
2466
|
# fred.instance_variable_defined?("@c") #=> false
|
2469
2467
|
#
|
2470
|
-
def instance_variable_defined?: (interned
|
2468
|
+
def instance_variable_defined?: (interned variable) -> bool
|
2471
2469
|
|
2472
2470
|
# <!--
|
2473
2471
|
# rdoc-file=object.c
|
@@ -2489,7 +2487,7 @@ module Kernel : BasicObject
|
|
2489
2487
|
# fred.instance_variable_get(:@a) #=> "cat"
|
2490
2488
|
# fred.instance_variable_get("@b") #=> 99
|
2491
2489
|
#
|
2492
|
-
def instance_variable_get: (interned
|
2490
|
+
def instance_variable_get: (interned variable) -> untyped
|
2493
2491
|
|
2494
2492
|
# <!--
|
2495
2493
|
# rdoc-file=object.c
|
@@ -2512,7 +2510,7 @@ module Kernel : BasicObject
|
|
2512
2510
|
# fred.instance_variable_set(:@c, 'cat') #=> "cat"
|
2513
2511
|
# fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">"
|
2514
2512
|
#
|
2515
|
-
def instance_variable_set: [
|
2513
|
+
def instance_variable_set: [T] (interned variable, T value) -> T
|
2516
2514
|
|
2517
2515
|
# <!--
|
2518
2516
|
# rdoc-file=object.c
|
@@ -2553,9 +2551,8 @@ module Kernel : BasicObject
|
|
2553
2551
|
# b.kind_of? C #=> false
|
2554
2552
|
# b.kind_of? M #=> true
|
2555
2553
|
#
|
2556
|
-
def is_a?: (Module) -> bool
|
2554
|
+
def is_a?: (Module | Class module_or_class) -> bool
|
2557
2555
|
|
2558
|
-
%a{annotate:rdoc:skip}
|
2559
2556
|
alias kind_of? is_a?
|
2560
2557
|
|
2561
2558
|
# <!--
|
@@ -2636,7 +2633,7 @@ module Kernel : BasicObject
|
|
2636
2633
|
# k.extend M123
|
2637
2634
|
# k.methods(false) #=> [:singleton_method]
|
2638
2635
|
#
|
2639
|
-
def methods: () -> Array[Symbol]
|
2636
|
+
def methods: (?boolish regular) -> Array[Symbol]
|
2640
2637
|
|
2641
2638
|
# <!--
|
2642
2639
|
# rdoc-file=object.c
|
@@ -2647,7 +2644,7 @@ module Kernel : BasicObject
|
|
2647
2644
|
# Object.new.nil? #=> false
|
2648
2645
|
# nil.nil? #=> true
|
2649
2646
|
#
|
2650
|
-
def nil?: () ->
|
2647
|
+
def nil?: () -> false
|
2651
2648
|
|
2652
2649
|
# <!--
|
2653
2650
|
# rdoc-file=gc.c
|
@@ -2672,7 +2669,7 @@ module Kernel : BasicObject
|
|
2672
2669
|
# "hello".object_id == "hello".object_id # => false
|
2673
2670
|
# "hi".freeze.object_id == "hi".freeze.object_id # => true
|
2674
2671
|
#
|
2675
|
-
|
2672
|
+
alias object_id __id__
|
2676
2673
|
|
2677
2674
|
# <!--
|
2678
2675
|
# rdoc-file=object.c
|
@@ -2682,7 +2679,7 @@ module Kernel : BasicObject
|
|
2682
2679
|
# parameter is set to `false`, only those methods in the receiver will be
|
2683
2680
|
# listed.
|
2684
2681
|
#
|
2685
|
-
def private_methods: () -> Array[Symbol]
|
2682
|
+
def private_methods: (?boolish all) -> Array[Symbol]
|
2686
2683
|
|
2687
2684
|
# <!--
|
2688
2685
|
# rdoc-file=object.c
|
@@ -2692,7 +2689,7 @@ module Kernel : BasicObject
|
|
2692
2689
|
# parameter is set to `false`, only those methods in the receiver will be
|
2693
2690
|
# listed.
|
2694
2691
|
#
|
2695
|
-
def protected_methods: () -> Array[Symbol]
|
2692
|
+
def protected_methods: (?boolish all) -> Array[Symbol]
|
2696
2693
|
|
2697
2694
|
# <!--
|
2698
2695
|
# rdoc-file=proc.c
|
@@ -2722,7 +2719,7 @@ module Kernel : BasicObject
|
|
2722
2719
|
#
|
2723
2720
|
# 1.public_send(:puts, "hello") # causes NoMethodError
|
2724
2721
|
#
|
2725
|
-
def public_send: (interned name, *untyped
|
2722
|
+
def public_send: (interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
|
2726
2723
|
|
2727
2724
|
# <!--
|
2728
2725
|
# rdoc-file=object.c
|
@@ -2746,7 +2743,7 @@ module Kernel : BasicObject
|
|
2746
2743
|
# d.remove #=> 99
|
2747
2744
|
# d.var #=> nil
|
2748
2745
|
#
|
2749
|
-
def remove_instance_variable: (interned
|
2746
|
+
def remove_instance_variable: (interned variable) -> untyped
|
2750
2747
|
|
2751
2748
|
# <!--
|
2752
2749
|
# rdoc-file=vm_method.c
|
@@ -2782,8 +2779,7 @@ module Kernel : BasicObject
|
|
2782
2779
|
#
|
2783
2780
|
# See #respond_to?, and the example of BasicObject.
|
2784
2781
|
#
|
2785
|
-
|
2786
|
-
private def respond_to_missing?: (Symbol, bool) -> bool
|
2782
|
+
private def respond_to_missing?: (Symbol | String name, bool include_all) -> bool
|
2787
2783
|
|
2788
2784
|
# <!--
|
2789
2785
|
# rdoc-file=vm_eval.c
|
@@ -2808,7 +2804,7 @@ module Kernel : BasicObject
|
|
2808
2804
|
# k = Klass.new
|
2809
2805
|
# k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
|
2810
2806
|
#
|
2811
|
-
|
2807
|
+
alias send __send__
|
2812
2808
|
|
2813
2809
|
# <!--
|
2814
2810
|
# rdoc-file=object.c
|
@@ -2883,7 +2879,7 @@ module Kernel : BasicObject
|
|
2883
2879
|
# a.singleton_methods(false) #=> [:two, :one]
|
2884
2880
|
# a.singleton_methods #=> [:two, :one, :three]
|
2885
2881
|
#
|
2886
|
-
def singleton_methods: () -> Array[Symbol]
|
2882
|
+
def singleton_methods: (?boolish all) -> Array[Symbol]
|
2887
2883
|
|
2888
2884
|
# <!--
|
2889
2885
|
# rdoc-file=kernel.rb
|
@@ -2919,17 +2915,50 @@ module Kernel : BasicObject
|
|
2919
2915
|
#
|
2920
2916
|
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
|
2921
2917
|
#
|
2922
|
-
def yield_self:
|
2923
|
-
| ()
|
2918
|
+
def yield_self: () -> Enumerator[self, untyped]
|
2919
|
+
| [T] () { (self) -> T } -> T
|
2924
2920
|
|
2925
|
-
|
2921
|
+
# <!--
|
2922
|
+
# rdoc-file=kernel.rb
|
2923
|
+
# - obj.then {|x| block } -> an_object
|
2924
|
+
# -->
|
2925
|
+
# Yields self to the block and returns the result of the block.
|
2926
|
+
#
|
2927
|
+
# 3.next.then {|x| x**x }.to_s #=> "256"
|
2928
|
+
#
|
2929
|
+
# Good usage for `then` is value piping in method chains:
|
2930
|
+
#
|
2931
|
+
# require 'open-uri'
|
2932
|
+
# require 'json'
|
2933
|
+
#
|
2934
|
+
# construct_url(arguments).
|
2935
|
+
# then {|url| URI(url).read }.
|
2936
|
+
# then {|response| JSON.parse(response) }
|
2937
|
+
#
|
2938
|
+
# When called without block, the method returns `Enumerator`, which can be used,
|
2939
|
+
# for example, for conditional circuit-breaking:
|
2940
|
+
#
|
2941
|
+
# # meets condition, no-op
|
2942
|
+
# 1.then.detect(&:odd?) # => 1
|
2943
|
+
# # does not meet condition, drop value
|
2944
|
+
# 2.then.detect(&:odd?) # => nil
|
2945
|
+
#
|
2946
|
+
# Good usage for `then` is value piping in method chains:
|
2947
|
+
#
|
2948
|
+
# require 'open-uri'
|
2949
|
+
# require 'json'
|
2950
|
+
#
|
2951
|
+
# construct_url(arguments).
|
2952
|
+
# then {|url| URI(url).read }.
|
2953
|
+
# then {|response| JSON.parse(response) }
|
2954
|
+
#
|
2926
2955
|
alias then yield_self
|
2927
2956
|
|
2928
|
-
private
|
2957
|
+
private
|
2929
2958
|
|
2930
|
-
|
2959
|
+
def initialize_copy: (instance object) -> self
|
2931
2960
|
|
2932
|
-
|
2933
|
-
end
|
2961
|
+
def initialize_clone: (instance object, ?freeze: bool?) -> self
|
2934
2962
|
|
2935
|
-
|
2963
|
+
def initialize_dup: (instance object) -> self
|
2964
|
+
end
|
data/core/method.rbs
CHANGED
@@ -22,9 +22,100 @@
|
|
22
22
|
# %w[2017-03-01 2017-03-02].collect(&Date.method(:parse))
|
23
23
|
# #=> [#<Date: 2017-03-01 ((2457814j,0s,0n),+0s,2299161j)>, #<Date: 2017-03-02 ((2457815j,0s,0n),+0s,2299161j)>]
|
24
24
|
#
|
25
|
-
class Method
|
25
|
+
class Method
|
26
|
+
# The return type from `#parameters` methods (such as those defined on `Method`, `Proc`, and `UnboundMethod`).
|
26
27
|
type param_types = Array[[:req | :opt | :rest | :keyreq | :key | :keyrest | :block, Symbol] | [:rest | :keyrest | :nokey]]
|
27
28
|
|
29
|
+
# <!--
|
30
|
+
# rdoc-file=proc.c
|
31
|
+
# - meth.eql?(other_meth) -> true or false
|
32
|
+
# - meth == other_meth -> true or false
|
33
|
+
# -->
|
34
|
+
# Two method objects are equal if they are bound to the same object and refer to
|
35
|
+
# the same method definition and the classes defining the methods are the same
|
36
|
+
# class or module.
|
37
|
+
#
|
38
|
+
def ==: (untyped other) -> bool
|
39
|
+
|
40
|
+
# <!-- rdoc-file=proc.c -->
|
41
|
+
# Two method objects are equal if they are bound to the same object and refer to
|
42
|
+
# the same method definition and the classes defining the methods are the same
|
43
|
+
# class or module.
|
44
|
+
#
|
45
|
+
alias eql? ==
|
46
|
+
|
47
|
+
# <!--
|
48
|
+
# rdoc-file=proc.c
|
49
|
+
# - meth.hash -> integer
|
50
|
+
# -->
|
51
|
+
# Returns a hash value corresponding to the method object.
|
52
|
+
#
|
53
|
+
# See also Object#hash.
|
54
|
+
#
|
55
|
+
def hash: () -> Integer
|
56
|
+
|
57
|
+
def dup: () -> instance
|
58
|
+
|
59
|
+
# <!--
|
60
|
+
# rdoc-file=proc.c
|
61
|
+
# - meth.to_s -> string
|
62
|
+
# - meth.inspect -> string
|
63
|
+
# -->
|
64
|
+
# Returns a human-readable description of the underlying method.
|
65
|
+
#
|
66
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
67
|
+
# (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>"
|
68
|
+
#
|
69
|
+
# In the latter case, the method description includes the "owner" of the
|
70
|
+
# original method (`Enumerable` module, which is included into `Range`).
|
71
|
+
#
|
72
|
+
# `inspect` also provides, when possible, method argument names (call sequence)
|
73
|
+
# and source location.
|
74
|
+
#
|
75
|
+
# require 'net/http'
|
76
|
+
# Net::HTTP.method(:get).inspect
|
77
|
+
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
78
|
+
#
|
79
|
+
# `...` in argument definition means argument is optional (has some default
|
80
|
+
# value).
|
81
|
+
#
|
82
|
+
# For methods defined in C (language core and extensions), location and argument
|
83
|
+
# names can't be extracted, and only generic information is provided in form of
|
84
|
+
# `*` (any number of arguments) or `_` (some positional argument).
|
85
|
+
#
|
86
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
87
|
+
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
88
|
+
#
|
89
|
+
def inspect: () -> String
|
90
|
+
|
91
|
+
# <!-- rdoc-file=proc.c -->
|
92
|
+
# Returns a human-readable description of the underlying method.
|
93
|
+
#
|
94
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
95
|
+
# (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map()>"
|
96
|
+
#
|
97
|
+
# In the latter case, the method description includes the "owner" of the
|
98
|
+
# original method (`Enumerable` module, which is included into `Range`).
|
99
|
+
#
|
100
|
+
# `inspect` also provides, when possible, method argument names (call sequence)
|
101
|
+
# and source location.
|
102
|
+
#
|
103
|
+
# require 'net/http'
|
104
|
+
# Net::HTTP.method(:get).inspect
|
105
|
+
# #=> "#<Method: Net::HTTP.get(uri_or_host, path=..., port=...) <skip>/lib/ruby/2.7.0/net/http.rb:457>"
|
106
|
+
#
|
107
|
+
# `...` in argument definition means argument is optional (has some default
|
108
|
+
# value).
|
109
|
+
#
|
110
|
+
# For methods defined in C (language core and extensions), location and argument
|
111
|
+
# names can't be extracted, and only generic information is provided in form of
|
112
|
+
# `*` (any number of arguments) or `_` (some positional argument).
|
113
|
+
#
|
114
|
+
# "cat".method(:count).inspect #=> "#<Method: String#count(*)>"
|
115
|
+
# "cat".method(:+).inspect #=> "#<Method: String#+(_)>""
|
116
|
+
#
|
117
|
+
alias to_s inspect
|
118
|
+
|
28
119
|
# <!--
|
29
120
|
# rdoc-file=proc.c
|
30
121
|
# - meth.to_proc -> proc
|
@@ -44,7 +135,7 @@ class Method < Object
|
|
44
135
|
# m.call(3) #=> 15
|
45
136
|
# m.call(20) #=> 32
|
46
137
|
#
|
47
|
-
def call: (
|
138
|
+
def call: (?) -> untyped
|
48
139
|
|
49
140
|
# <!--
|
50
141
|
# rdoc-file=proc.c
|
@@ -62,7 +153,7 @@ class Method < Object
|
|
62
153
|
# g = proc {|x| x + x }
|
63
154
|
# p (f << g).call(2) #=> 16
|
64
155
|
#
|
65
|
-
def <<: (Proc g) -> Proc
|
156
|
+
def <<: (Proc::_Callable g) -> Proc
|
66
157
|
|
67
158
|
# <!-- rdoc-file=proc.c -->
|
68
159
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
@@ -90,7 +181,7 @@ class Method < Object
|
|
90
181
|
# g = proc {|x| x + x }
|
91
182
|
# p (f >> g).call(2) #=> 8
|
92
183
|
#
|
93
|
-
def >>: (Proc g) -> Proc
|
184
|
+
def >>: (Proc::_Callable g) -> Proc
|
94
185
|
|
95
186
|
# <!-- rdoc-file=proc.c -->
|
96
187
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
@@ -161,7 +252,7 @@ class Method < Object
|
|
161
252
|
# m.call # => "bar"
|
162
253
|
# n = m.clone.call # => "bar"
|
163
254
|
#
|
164
|
-
def clone: () ->
|
255
|
+
def clone: () -> instance
|
165
256
|
|
166
257
|
# <!--
|
167
258
|
# rdoc-file=proc.c
|
@@ -194,7 +285,7 @@ class Method < Object
|
|
194
285
|
# proc3 = proc2.call(:y, :z) #=> #<Proc>
|
195
286
|
# proc3.call(:a) #=> [:x, :y, :z, :a]
|
196
287
|
#
|
197
|
-
def curry: (?
|
288
|
+
def curry: (?int? arity) -> Proc
|
198
289
|
|
199
290
|
# <!--
|
200
291
|
# rdoc-file=proc.c
|
@@ -273,7 +364,7 @@ class Method < Object
|
|
273
364
|
# Returns the Ruby source filename and line number containing this method or nil
|
274
365
|
# if this method was not defined in Ruby (i.e. native).
|
275
366
|
#
|
276
|
-
def source_location: () -> [
|
367
|
+
def source_location: () -> [String, Integer]?
|
277
368
|
|
278
369
|
# <!--
|
279
370
|
# rdoc-file=proc.c
|
data/core/module.rbs
CHANGED
@@ -396,7 +396,7 @@ class Module < Object
|
|
396
396
|
#
|
397
397
|
# Hello there!
|
398
398
|
#
|
399
|
-
def class_exec: [U] (*untyped
|
399
|
+
def class_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
400
400
|
|
401
401
|
# <!--
|
402
402
|
# rdoc-file=object.c
|
@@ -904,7 +904,7 @@ class Module < Object
|
|
904
904
|
# Assign the module to a constant (name starting uppercase) if you want to treat
|
905
905
|
# it like a regular module.
|
906
906
|
#
|
907
|
-
def initialize: () ->
|
907
|
+
def initialize: () -> void
|
908
908
|
| () { (Module arg0) -> untyped } -> void
|
909
909
|
|
910
910
|
# <!--
|
@@ -1106,7 +1106,7 @@ class Module < Object
|
|
1106
1106
|
#
|
1107
1107
|
# Hello there!
|
1108
1108
|
#
|
1109
|
-
def module_exec: [U] (*untyped
|
1109
|
+
def module_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
|
1110
1110
|
|
1111
1111
|
# <!--
|
1112
1112
|
# rdoc-file=vm_method.c
|