rbs 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.gitignore +0 -1
  4. data/CHANGELOG.md +7 -2
  5. data/Gemfile +3 -0
  6. data/README.md +8 -2
  7. data/Steepfile +1 -0
  8. data/bin/annotate-with-rdoc +1 -1
  9. data/bin/setup +0 -2
  10. data/docs/CONTRIBUTING.md +1 -0
  11. data/goodcheck.yml +22 -5
  12. data/lib/rbs/ast/comment.rb +1 -1
  13. data/lib/rbs/definition_builder.rb +4 -5
  14. data/lib/rbs/environment.rb +1 -1
  15. data/lib/rbs/namespace.rb +1 -1
  16. data/lib/rbs/parser.rb +3146 -0
  17. data/lib/rbs/parser.y +7 -2
  18. data/lib/rbs/test/setup_helper.rb +4 -4
  19. data/lib/rbs/test/type_check.rb +2 -2
  20. data/lib/rbs/type_name.rb +1 -1
  21. data/lib/rbs/variance_calculator.rb +1 -1
  22. data/lib/rbs/version.rb +1 -1
  23. data/lib/rbs/writer.rb +1 -1
  24. data/sig/constant.rbs +2 -2
  25. data/sig/constant_table.rbs +10 -10
  26. data/sig/declarations.rbs +1 -1
  27. data/sig/definition.rbs +1 -1
  28. data/sig/namespace.rbs +3 -3
  29. data/sig/parser.rbs +25 -0
  30. data/sig/substitution.rbs +3 -3
  31. data/sig/typename.rbs +1 -1
  32. data/sig/types.rbs +1 -1
  33. data/sig/writer.rbs +15 -15
  34. data/stdlib/benchmark/benchmark.rbs +2 -2
  35. data/stdlib/builtin/basic_object.rbs +54 -54
  36. data/stdlib/builtin/binding.rbs +42 -42
  37. data/stdlib/builtin/class.rbs +33 -33
  38. data/stdlib/builtin/complex.rbs +90 -90
  39. data/stdlib/builtin/encoding.rbs +33 -33
  40. data/stdlib/builtin/enumerable.rbs +32 -32
  41. data/stdlib/builtin/enumerator.rbs +35 -35
  42. data/stdlib/builtin/errors.rbs +1 -1
  43. data/stdlib/builtin/exception.rbs +50 -50
  44. data/stdlib/builtin/false_class.rbs +6 -6
  45. data/stdlib/builtin/fiber.rbs +14 -14
  46. data/stdlib/builtin/fiber_error.rbs +1 -1
  47. data/stdlib/builtin/float.rbs +161 -161
  48. data/stdlib/builtin/gc.rbs +1 -1
  49. data/stdlib/builtin/io.rbs +83 -83
  50. data/stdlib/builtin/kernel.rbs +69 -69
  51. data/stdlib/builtin/match_data.rbs +1 -1
  52. data/stdlib/builtin/method.rbs +19 -19
  53. data/stdlib/builtin/nil_class.rbs +20 -20
  54. data/stdlib/builtin/numeric.rbs +101 -101
  55. data/stdlib/builtin/object.rbs +172 -172
  56. data/stdlib/builtin/proc.rbs +91 -91
  57. data/stdlib/builtin/range.rbs +2 -4
  58. data/stdlib/builtin/rational.rbs +83 -83
  59. data/stdlib/builtin/signal.rbs +7 -7
  60. data/stdlib/builtin/string.rbs +4 -4
  61. data/stdlib/builtin/string_io.rbs +1 -1
  62. data/stdlib/builtin/thread.rbs +185 -185
  63. data/stdlib/builtin/thread_group.rbs +2 -2
  64. data/stdlib/builtin/true_class.rbs +9 -9
  65. data/stdlib/builtin/warning.rbs +1 -1
  66. data/stdlib/date/date.rbs +2 -2
  67. data/stdlib/find/find.rbs +10 -10
  68. data/stdlib/pathname/pathname.rbs +1 -1
  69. data/stdlib/tmpdir/tmpdir.rbs +12 -12
  70. metadata +3 -2
@@ -1,5 +1,6 @@
1
1
  class RBS::Parser
2
- token tUIDENT tLIDENT tNAMESPACE tINTERFACEIDENT tLKEYWORD tUKEYWORD tGLOBALIDENT
2
+ token tUIDENT tLIDENT tNAMESPACE tINTERFACEIDENT tGLOBALIDENT
3
+ tLKEYWORD tUKEYWORD tLKEYWORD_Q_E tUKEYWORD_Q_E
3
4
  tIVAR tCLASSVAR
4
5
  tANNOTATION
5
6
  tSTRING tSYMBOL tINTEGER tWRITE_ATTR
@@ -846,7 +847,7 @@ rule
846
847
  result = val[0]
847
848
  }
848
849
 
849
- keyword: tLKEYWORD | tUKEYWORD
850
+ keyword: tLKEYWORD | tUKEYWORD | tLKEYWORD_Q_E | tUKEYWORD_Q_E
850
851
 
851
852
  function_type:
852
853
  kLPAREN params kRPAREN kARROW simple_type {
@@ -1344,8 +1345,12 @@ def next_token
1344
1345
  new_token(:tNAMESPACE)
1345
1346
  when input.scan(/[a-z_]\w*:/)
1346
1347
  new_token(:tLKEYWORD, input.matched.chop.to_sym)
1348
+ when input.scan(/[a-z_]\w*[?!]:/)
1349
+ new_token(:tLKEYWORD_Q_E, input.matched.chop.to_sym)
1347
1350
  when input.scan(/[A-Z]\w*:/)
1348
1351
  new_token(:tUKEYWORD, input.matched.chop.to_sym)
1352
+ when input.scan(/[A-Z]\w*[?!]:/)
1353
+ new_token(:tUKEYWORD_Q_E, input.matched.chop.to_sym)
1349
1354
  when input.scan(/\$[A-Za-z_]\w*/)
1350
1355
  new_token(:tGLOBALIDENT)
1351
1356
  when input.scan(/@[a-zA-Z_]\w*/)
@@ -3,15 +3,15 @@ module RBS
3
3
  module SetupHelper
4
4
  class InvalidSampleSizeError < StandardError
5
5
  attr_reader :string
6
-
6
+
7
7
  def initialize(string)
8
8
  @string = string
9
9
  super("Sample size should be a positive integer: `#{string}`")
10
10
  end
11
11
  end
12
-
12
+
13
13
  DEFAULT_SAMPLE_SIZE = 100
14
-
14
+
15
15
  def get_sample_size(string)
16
16
  case string
17
17
  when ""
@@ -32,7 +32,7 @@ module RBS
32
32
  when 'rspec'
33
33
  ['::RSpec::Mocks::Double']
34
34
  when 'minitest'
35
- ['::Minitest::Mock']
35
+ ['::Minitest::Mock']
36
36
  else
37
37
  RBS.logger.warn "Unknown test suite - defaults to nil"
38
38
  nil
@@ -212,7 +212,7 @@ module RBS
212
212
  def value(val, type)
213
213
  if is_double?(val)
214
214
  RBS.logger.info("A double (#{val.inspect}) is detected!")
215
- return true
215
+ return true
216
216
  end
217
217
 
218
218
  case type
@@ -306,7 +306,7 @@ module RBS
306
306
  Test.call(val, IS_AP, ::Array) &&
307
307
  type.types.map.with_index {|ty, index| value(val[index], ty) }.all?
308
308
  when Types::Record
309
- Test::call(val, IS_AP, ::Hash) &&
309
+ Test::call(val, IS_AP, ::Hash) &&
310
310
  type.fields.map {|key, type| value(val[key], type) }.all?
311
311
  when Types::Proc
312
312
  Test::call(val, IS_AP, ::Proc)
@@ -23,7 +23,7 @@ module RBS
23
23
  def ==(other)
24
24
  other.is_a?(self.class) && other.namespace == namespace && other.name == name
25
25
  end
26
-
26
+
27
27
  alias eql? ==
28
28
 
29
29
  def hash
@@ -135,7 +135,7 @@ module RBS
135
135
  when :contravariant
136
136
  :covariant
137
137
  else
138
- raise
138
+ raise
139
139
  end
140
140
  type(ty, result: result, context: con)
141
141
  end
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "0.13.1"
2
+ VERSION = "0.14.0"
3
3
  end
@@ -305,7 +305,7 @@ module RBS
305
305
  if prev_loc && decl_loc
306
306
  prev_end_line = prev_loc.end_line
307
307
  start_line = decl_loc.start_line
308
-
308
+
309
309
  if start_line - prev_end_line > 1
310
310
  puts
311
311
  end
@@ -11,9 +11,9 @@ module RBS
11
11
  attr_reader entry: constant_entry
12
12
 
13
13
  def initialize: (name: TypeName, type: Types::t, entry: constant_entry) -> void
14
-
14
+
15
15
  def ==: (untyped other) -> bool
16
-
16
+
17
17
  alias eql? ==
18
18
 
19
19
  def hash: () -> Integer
@@ -6,25 +6,25 @@ module RBS
6
6
  attr_reader env(): Environment
7
7
 
8
8
  def initialize: (builder: DefinitionBuilder) -> void
9
-
9
+
10
10
  def absolute_type: (Types::t, context: Array[Namespace]) -> Types::t
11
-
11
+
12
12
  def absolute_type_name: (TypeName, context: Array[Namespace], location: Location?) -> TypeName
13
-
13
+
14
14
  def name_to_constant: (TypeName) -> Constant?
15
-
15
+
16
16
  def split_name: (TypeName) -> Array[Symbol]
17
-
17
+
18
18
  def resolve_constant_reference: (TypeName name, context: Array[Namespace]) -> Constant?
19
-
19
+
20
20
  def resolve_constant_reference_context: (Symbol, context: Array[Namespace]) -> Constant?
21
-
21
+
22
22
  def resolve_constant_reference_inherit: (Symbol, scopes: Array[Namespace], ?no_object: bool) -> Constant?
23
-
23
+
24
24
  def constant_scopes: (TypeName) -> Array[Namespace]
25
-
25
+
26
26
  def constant_scopes_module: (TypeName, scopes: Array[Namespace]) -> Array[Namespace]
27
-
27
+
28
28
  def constant_scopes0: (TypeName, ?scopes: Array[Namespace]) -> Array[Namespace]
29
29
  end
30
30
  end
@@ -2,7 +2,7 @@ module RBS
2
2
  module AST
3
3
  module Declarations
4
4
  type t = Class | Module | Interface | Constant | Global | Alias
5
-
5
+
6
6
  class Base
7
7
  end
8
8
 
@@ -28,7 +28,7 @@ module RBS
28
28
  def annotations: () -> Array[AST::Annotation]
29
29
 
30
30
  def update: (?type: MethodType, ?member: method_member, ?defined_in: TypeName?, ?implemented_in: TypeName?) -> TypeDef
31
-
31
+
32
32
  def overload?: () -> bool
33
33
  end
34
34
 
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # Namespace instance represents a _prefix of module names_.
3
- #
3
+ #
4
4
  # vvvvvvvvvvvvvv TypeName
5
5
  # RBS::Namespace
6
6
  # ^^^^^ Namespace
@@ -44,7 +44,7 @@ module RBS
44
44
  # If `other` is an absolute namespace, it returns `other`.
45
45
  #
46
46
  # Namespace("Foo::") + Namespace("::Bar::") # => ::Bar::
47
- #
47
+ #
48
48
  def +: (Namespace other) -> Namespace
49
49
 
50
50
  # Add one path component to self.
@@ -62,7 +62,7 @@ module RBS
62
62
 
63
63
  # Returns true if self is absolute namespace.
64
64
  def absolute?: () -> bool
65
-
65
+
66
66
  # Returns true if self is relative namespace.
67
67
  def relative?: () -> bool
68
68
 
@@ -0,0 +1,25 @@
1
+ module RBS
2
+ class Parser
3
+ class SyntaxError < StandardError
4
+ attr_reader token_str: String
5
+ attr_reader error_value: untyped
6
+ attr_reader value_stack: untyped?
7
+
8
+ def initialize: (token_str: String, error_value: untyped, ?value_stack: untyped?) -> void
9
+ end
10
+
11
+ class SemanticsError < StandardError
12
+ attr_reader subject: untyped
13
+ attr_reader location: Location
14
+ attr_reader original_message: String
15
+
16
+ def initialize: (String message, subject: untyped, location: Location) -> void
17
+ end
18
+
19
+ def self.parse_method_type: (String | Buffer, ?variables: Array[Symbol], ?eof_re: Regexp?) -> MethodType
20
+
21
+ def self.parse_type: (String | Buffer, ?variables: Array[Symbol], ?eof_re: Regexp?) -> Types::t
22
+
23
+ def self.parse_signature: (String | Buffer, ?eof_re: Regexp?) -> Array[AST::Declarations::t]
24
+ end
25
+ end
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # Substitution from type variables to types.
3
- #
3
+ #
4
4
  # The substitution construction is in _destructive_ manner.
5
5
  #
6
6
  # sub = Substitution.new
@@ -25,7 +25,7 @@ module RBS
25
25
  # Utility method to construct a substitution.
26
26
  # Raises an error when `variables.size != types.size`.
27
27
  # `instance_type` defaults to `nil`.
28
- #
28
+ #
29
29
  # Yields types in `types` and the block value is used if block is given.
30
30
  #
31
31
  def self.build: (Array[Symbol] variables, Array[Types::t] types, ?instance_type: Types::t?) ?{ (Types::t) -> Types::t } -> instance
@@ -36,4 +36,4 @@ module RBS
36
36
  # Returns a substitution without variables given in `vars`.
37
37
  def without: (*Symbol vars) -> Substitution
38
38
  end
39
- end
39
+ end
@@ -1,6 +1,6 @@
1
1
  module RBS
2
2
  # TypeName represents name of types in RBS.
3
- #
3
+ #
4
4
  # TypeNames are one of the three kind, class, alias, and interface.
5
5
  # *class* type names corresponds to Ruby classes and modules.
6
6
  # There are no corresponding Ruby value to *alias* and *interface* type names.
@@ -154,7 +154,7 @@ module RBS
154
154
 
155
155
  include NoFreeVariables
156
156
  include NoSubst
157
- include EmptyEachType
157
+ include EmptyEachType
158
158
  end
159
159
 
160
160
  module Application
@@ -4,37 +4,37 @@ module RBS
4
4
  attr_reader indentation: Array[String]
5
5
 
6
6
  def initialize: (out: IO) -> void
7
-
7
+
8
8
  def indent: (?Integer size) { () -> void } -> void
9
-
9
+
10
10
  def prefix: () -> String
11
-
11
+
12
12
  def puts: (?String) -> void
13
-
13
+
14
14
  def write_annotation: (Array[AST::Annotation]) -> void
15
-
15
+
16
16
  def write_comment: (AST::Comment?) -> void
17
-
17
+
18
18
  def write: (Array[AST::Declarations::t]) -> void
19
-
19
+
20
20
  def write_decl: (AST::Declarations::t) -> void
21
-
21
+
22
22
  def write_member: (AST::Declarations::Module::member) -> void
23
-
23
+
24
24
  def name_and_params: (TypeName, AST::Declarations::ModuleTypeParams) -> String?
25
-
25
+
26
26
  def name_and_args: (TypeName, Array[Types::t]) -> String?
27
-
27
+
28
28
  def method_name: (Symbol) -> String
29
-
29
+
30
30
  def write_def: (AST::Members::MethodDefinition) -> void
31
-
31
+
32
32
  def attribute: (:reader | :writer | :accessor, AST::Members::Attribute) -> void
33
-
33
+
34
34
  interface _Located
35
35
  def location: () -> Location?
36
36
  end
37
-
37
+
38
38
  def preserve_empty_line: (_Located?, _Located) -> void
39
39
  end
40
40
  end
@@ -53,9 +53,9 @@
53
53
  # times: 1.000000 0.000000 1.000000 ( 1.003611)
54
54
  # upto: 1.030000 0.000000 1.030000 ( 1.028098)
55
55
  #
56
- # * The times for some benchmarks depend on the order in which items are run.
56
+ # * The times for some benchmarks depend on the order in which items are run.
57
57
  # These differences are due to the cost of memory allocation and garbage
58
- # collection. To avoid these discrepancies, the #bmbm method is provided.
58
+ # collection. To avoid these discrepancies, the #bmbm method is provided.
59
59
  # For example, to compare ways to sort an array of floats:
60
60
  #
61
61
  # require 'benchmark'
@@ -1,108 +1,108 @@
1
1
  # BasicObject is the parent class of all classes in Ruby. It's an explicit
2
2
  # blank class.
3
- #
3
+ #
4
4
  # BasicObject can be used for creating object hierarchies independent of Ruby's
5
5
  # object hierarchy, proxy objects like the Delegator class, or other uses where
6
6
  # namespace pollution from Ruby's methods and classes must be avoided.
7
- #
7
+ #
8
8
  # To avoid polluting BasicObject for other users an appropriately named subclass
9
9
  # of BasicObject should be created instead of directly modifying BasicObject:
10
- #
10
+ #
11
11
  # class MyObjectSystem < BasicObject
12
12
  # end
13
- #
13
+ #
14
14
  # BasicObject does not include Kernel (for methods like `puts`) and BasicObject
15
15
  # is outside of the namespace of the standard library so common classes will not
16
16
  # be found without using a full class path.
17
- #
17
+ #
18
18
  # A variety of strategies can be used to provide useful portions of the standard
19
19
  # library to subclasses of BasicObject. A subclass could `include Kernel` to
20
20
  # obtain `puts`, `exit`, etc. A custom Kernel-like module could be created and
21
21
  # included or delegation can be used via #method_missing:
22
- #
22
+ #
23
23
  # class MyObjectSystem < BasicObject
24
24
  # DELEGATE = [:puts, :p]
25
- #
25
+ #
26
26
  # def method_missing(name, *args, &block)
27
27
  # super unless DELEGATE.include? name
28
28
  # ::Kernel.send(name, *args, &block)
29
29
  # end
30
- #
30
+ #
31
31
  # def respond_to_missing?(name, include_private = false)
32
32
  # DELEGATE.include?(name) or super
33
33
  # end
34
34
  # end
35
- #
35
+ #
36
36
  # Access to classes and modules from the Ruby standard library can be obtained
37
37
  # in a BasicObject subclass by referencing the desired constant from the root
38
38
  # like `::File` or `::Enumerator`. Like #method_missing, #const_missing can be
39
39
  # used to delegate constant lookup to `Object`:
40
- #
40
+ #
41
41
  # class MyObjectSystem < BasicObject
42
42
  # def self.const_missing(name)
43
43
  # ::Object.const_get(name)
44
44
  # end
45
45
  # end
46
- #
46
+ #
47
47
  class BasicObject
48
48
  # Boolean negate.
49
- #
49
+ #
50
50
  def !: () -> bool
51
51
 
52
52
  # Returns true if two objects are not-equal, otherwise false.
53
- #
53
+ #
54
54
  def !=: (untyped other) -> bool
55
55
 
56
56
  # Equality --- At the `Object` level, `==` returns `true` only if `obj` and
57
57
  # `other` are the same object. Typically, this method is overridden in
58
58
  # descendant classes to provide class-specific meaning.
59
- #
59
+ #
60
60
  # Unlike `==`, the `equal?` method should never be overridden by subclasses as
61
61
  # it is used to determine object identity (that is, `a.equal?(b)` if and only if
62
62
  # `a` is the same object as `b`):
63
- #
63
+ #
64
64
  # obj = "a"
65
65
  # other = obj.dup
66
- #
66
+ #
67
67
  # obj == other #=> true
68
68
  # obj.equal? other #=> false
69
69
  # obj.equal? obj #=> true
70
- #
70
+ #
71
71
  # The `eql?` method returns `true` if `obj` and `other` refer to the same hash
72
72
  # key. This is used by Hash to test members for equality. For objects of class
73
73
  # `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
74
74
  # tradition by aliasing `eql?` to their overridden `==` method, but there are
75
75
  # exceptions. `Numeric` types, for example, perform type conversion across
76
76
  # `==`, but not across `eql?`, so:
77
- #
77
+ #
78
78
  # 1 == 1.0 #=> true
79
79
  # 1.eql? 1.0 #=> false
80
- #
80
+ #
81
81
  def ==: (untyped other) -> bool
82
82
 
83
83
  # Returns an integer identifier for `obj`.
84
- #
84
+ #
85
85
  # The same number will be returned on all calls to `object_id` for a given
86
86
  # object, and no two active objects will share an id.
87
- #
87
+ #
88
88
  # Note: that some objects of builtin classes are reused for optimization. This
89
89
  # is the case for immediate values and frozen string literals.
90
- #
90
+ #
91
91
  # Immediate values are not passed by reference but are passed by value: `nil`,
92
92
  # `true`, `false`, Fixnums, Symbols, and some Floats.
93
- #
93
+ #
94
94
  # Object.new.object_id == Object.new.object_id # => false
95
95
  # (21 * 2).object_id == (21 * 2).object_id # => true
96
96
  # "hello".object_id == "hello".object_id # => false
97
97
  # "hi".freeze.object_id == "hi".freeze.object_id # => true
98
- #
98
+ #
99
99
  def __id__: () -> Integer
100
100
 
101
101
  # Invokes the method identified by *symbol*, passing it any arguments specified.
102
102
  # You can use `__send__` if the name `send` clashes with an existing method in
103
103
  # *obj*. When the method is identified by a string, the string is converted to a
104
104
  # symbol.
105
- #
105
+ #
106
106
  # class Klass
107
107
  # def hello(*args)
108
108
  # "Hello " + args.join(' ')
@@ -110,48 +110,48 @@ class BasicObject
110
110
  # end
111
111
  # k = Klass.new
112
112
  # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
113
- #
113
+ #
114
114
  def __send__: (String | Symbol arg0, *untyped args) -> untyped
115
115
 
116
116
  # Equality --- At the `Object` level, `==` returns `true` only if `obj` and
117
117
  # `other` are the same object. Typically, this method is overridden in
118
118
  # descendant classes to provide class-specific meaning.
119
- #
119
+ #
120
120
  # Unlike `==`, the `equal?` method should never be overridden by subclasses as
121
121
  # it is used to determine object identity (that is, `a.equal?(b)` if and only if
122
122
  # `a` is the same object as `b`):
123
- #
123
+ #
124
124
  # obj = "a"
125
125
  # other = obj.dup
126
- #
126
+ #
127
127
  # obj == other #=> true
128
128
  # obj.equal? other #=> false
129
129
  # obj.equal? obj #=> true
130
- #
130
+ #
131
131
  # The `eql?` method returns `true` if `obj` and `other` refer to the same hash
132
132
  # key. This is used by Hash to test members for equality. For objects of class
133
133
  # `Object`, `eql?` is synonymous with `==`. Subclasses normally continue this
134
134
  # tradition by aliasing `eql?` to their overridden `==` method, but there are
135
135
  # exceptions. `Numeric` types, for example, perform type conversion across
136
136
  # `==`, but not across `eql?`, so:
137
- #
137
+ #
138
138
  # 1 == 1.0 #=> true
139
139
  # 1.eql? 1.0 #=> false
140
- #
140
+ #
141
141
  def equal?: (untyped other) -> bool
142
142
 
143
143
  # Evaluates a string containing Ruby source code, or the given block, within the
144
144
  # context of the receiver (*obj*). In order to set the context, the variable
145
145
  # `self` is set to *obj* while the code is executing, giving the code access to
146
146
  # *obj*'s instance variables and private methods.
147
- #
147
+ #
148
148
  # When `instance_eval` is given a block, *obj* is also passed in as the block's
149
149
  # only argument.
150
- #
150
+ #
151
151
  # When `instance_eval` is given a `String`, the optional second and third
152
152
  # parameters supply a filename and starting line number that are used when
153
153
  # reporting compilation errors.
154
- #
154
+ #
155
155
  # class KlassWithSecret
156
156
  # def initialize
157
157
  # @secret = 99
@@ -165,7 +165,7 @@ class BasicObject
165
165
  # k.instance_eval { @secret } #=> 99
166
166
  # k.instance_eval { the_secret } #=> "Ssssh! The secret is 99."
167
167
  # k.instance_eval {|obj| obj == self } #=> true
168
- #
168
+ #
169
169
  def instance_eval: (String, ?String filename, ?Integer lineno) -> untyped
170
170
  | [U] () { (self) -> U } -> U
171
171
 
@@ -173,7 +173,7 @@ class BasicObject
173
173
  # to set the context, the variable `self` is set to *obj* while the code is
174
174
  # executing, giving the code access to *obj*'s instance variables. Arguments
175
175
  # are passed as block parameters.
176
- #
176
+ #
177
177
  # class KlassWithSecret
178
178
  # def initialize
179
179
  # @secret = 99
@@ -181,11 +181,11 @@ class BasicObject
181
181
  # end
182
182
  # k = KlassWithSecret.new
183
183
  # k.instance_exec(5) {|x| @secret+x } #=> 104
184
- #
184
+ #
185
185
  def instance_exec: [U, V] (*V args) { (*V args) -> U } -> U
186
186
 
187
187
  # Not documented
188
- #
188
+ #
189
189
  def initialize: () -> void
190
190
 
191
191
  private
@@ -199,7 +199,7 @@ class BasicObject
199
199
  # method. The example below creates a class `Roman`, which responds to methods
200
200
  # with names consisting of roman numerals, returning the corresponding integer
201
201
  # values.
202
- #
202
+ #
203
203
  # class Roman
204
204
  # def roman_to_int(str)
205
205
  # # ...
@@ -209,16 +209,16 @@ class BasicObject
209
209
  # roman_to_int(str)
210
210
  # end
211
211
  # end
212
- #
212
+ #
213
213
  # r = Roman.new
214
214
  # r.iv #=> 4
215
215
  # r.xxiii #=> 23
216
216
  # r.mm #=> 2000
217
- #
217
+ #
218
218
  def method_missing: (Symbol, *untyped) -> untyped
219
219
 
220
220
  # Invoked as a callback whenever a singleton method is added to the receiver.
221
- #
221
+ #
222
222
  # module Chatty
223
223
  # def Chatty.singleton_method_added(id)
224
224
  # puts "Adding #{id.id2name}"
@@ -227,18 +227,18 @@ class BasicObject
227
227
  # def two() end
228
228
  # def Chatty.three() end
229
229
  # end
230
- #
230
+ #
231
231
  # *produces:*
232
- #
232
+ #
233
233
  # Adding singleton_method_added
234
234
  # Adding one
235
235
  # Adding three
236
- #
236
+ #
237
237
  def singleton_method_added: (Symbol) -> void
238
238
 
239
239
  # Invoked as a callback whenever a singleton method is removed from the
240
240
  # receiver.
241
- #
241
+ #
242
242
  # module Chatty
243
243
  # def Chatty.singleton_method_removed(id)
244
244
  # puts "Removing #{id.id2name}"
@@ -251,17 +251,17 @@ class BasicObject
251
251
  # remove_method :one
252
252
  # end
253
253
  # end
254
- #
254
+ #
255
255
  # *produces:*
256
- #
256
+ #
257
257
  # Removing three
258
258
  # Removing one
259
- #
259
+ #
260
260
  def singleton_method_removed: (Symbol) -> void
261
261
 
262
262
  # Invoked as a callback whenever a singleton method is undefined in the
263
263
  # receiver.
264
- #
264
+ #
265
265
  # module Chatty
266
266
  # def Chatty.singleton_method_undefined(id)
267
267
  # puts "Undefining #{id.id2name}"
@@ -271,10 +271,10 @@ class BasicObject
271
271
  # undef_method(:one)
272
272
  # end
273
273
  # end
274
- #
274
+ #
275
275
  # *produces:*
276
- #
276
+ #
277
277
  # Undefining one
278
- #
278
+ #
279
279
  def singleton_method_undefined: (Symbol) -> void
280
280
  end