rbs 1.0.0.pre → 1.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,13 @@
1
1
  module RBS
2
- interface _Kinded
2
+ interface _MethodName
3
3
  def kind: () -> (:instance | :singleton)
4
+
5
+ def type_name: () -> TypeName
6
+
7
+ def method_name: () -> Symbol
4
8
  end
5
9
 
6
- module MethodNameHelper : _Kinded
10
+ module MethodNameHelper : _MethodName
7
11
  def method_name_string: () -> String
8
12
  end
9
13
 
@@ -17,4 +21,139 @@ module RBS
17
21
 
18
22
  def self.check!: (type_name: TypeName, args: Array[Types::t], params: Array[Symbol], location: Location?) -> void
19
23
  end
24
+
25
+ class RecursiveAncestorError < StandardError
26
+ attr_reader ancestors: Array[Definition::Ancestor::t]
27
+ attr_reader location: Location
28
+
29
+ def initialize: (ancestors: Array[Definition::Ancestor::t], location: Location?) -> void
30
+
31
+ def self.check!: (Definition::Ancestor::t, ancestors: Array[Definition::Ancestor::t], location: Location?) -> void
32
+ end
33
+
34
+ class NoTypeFoundError < StandardError
35
+ attr_reader type_name: TypeName
36
+ attr_reader location: Location?
37
+
38
+ def initialize: (type_name: TypeName, location: Location?) -> void
39
+
40
+ def self.check!: (TypeName, env: Environment, location: Location?) -> TypeName
41
+ end
42
+
43
+ class NoSuperclassFoundError < StandardError
44
+ attr_reader type_name: TypeName
45
+ attr_reader location: Location?
46
+
47
+ def initialize: (type_name: TypeName, location: Location?) -> void
48
+
49
+ def self.check!: (TypeName, env: Environment, location: Location?) -> void
50
+ end
51
+
52
+ class NoSelfTypeFoundError < StandardError
53
+ attr_reader type_name: TypeName
54
+ attr_reader location: Location?
55
+
56
+ def initialize: (type_name: TypeName, location: Location?) -> void
57
+
58
+ def self.check!: (AST::Declarations::Module::Self, env: Environment) -> void
59
+ end
60
+
61
+ class NoMixinFoundError < StandardError
62
+ attr_reader type_name: TypeName
63
+ attr_reader member: AST::Members::t
64
+
65
+ def initialize: (type_name: TypeName, member: AST::Members::t) -> void
66
+
67
+ def location: () -> Location?
68
+
69
+ def self.check!: (TypeName, env: Environment, member: AST::Members::t) -> void
70
+ end
71
+
72
+ class DuplicatedMethodDefinitionError < StandardError
73
+ type ty = Types::ClassSingleton | Types::ClassInstance | Types::Interface
74
+ type original = DefinitionBuilder::MethodBuilder::Methods::Definition::original
75
+
76
+ attr_reader type: ty
77
+ attr_reader method_name: Symbol
78
+ attr_reader members: Array[original]
79
+
80
+ def initialize: (type: ty, method_name: Symbol, members: Array[original]) -> void
81
+
82
+ def qualified_method_name: () -> String
83
+
84
+ def location: () -> Location?
85
+
86
+ def other_locations: () -> Array[Location?]
87
+ end
88
+
89
+ class DuplicatedInterfaceMethodDefinitionError < StandardError
90
+ type ty = Types::ClassSingleton | Types::ClassInstance | Types::Interface
91
+ type mixin_member = AST::Members::Include | AST::Members::Extend
92
+
93
+ attr_reader type: ty
94
+ attr_reader method_name: Symbol
95
+ attr_reader member: mixin_member
96
+
97
+ def initialize: (type: ty, method_name: Symbol, member: mixin_member) -> void
98
+
99
+ def qualified_method_name: () -> String
100
+ end
101
+
102
+ class UnknownMethodAliasError < StandardError
103
+ attr_reader original_name: Symbol
104
+ attr_reader aliased_name: Symbol
105
+ attr_reader location: Location?
106
+
107
+ def initialize: (original_name: Symbol, aliased_name: Symbol, location: Location?) -> void
108
+ end
109
+
110
+ class SuperclassMismatchError < StandardError
111
+ attr_reader name: TypeName
112
+ attr_reader entry: Environment::ClassEntry
113
+
114
+ def initialize: (name: TypeName, entry: Environment::ClassEntry) -> void
115
+ end
116
+
117
+ class InvalidOverloadMethodError < StandardError
118
+ attr_reader type_name: TypeName
119
+ attr_reader method_name: Symbol
120
+ attr_reader kind: :instance | :singleton
121
+ attr_reader members: Array[AST::Members::MethodDefinition]
122
+
123
+ def initialize: (type_name: TypeName, method_name: Symbol, kind: :instance | :singleton, members: Array[AST::Members::MethodDefinition]) -> void
124
+ end
125
+
126
+ class GenericParameterMismatchError < StandardError
127
+ attr_reader name: TypeName
128
+ attr_reader decl: AST::Declarations::Class | AST::Declarations::Module
129
+
130
+ def initialize: (name: TypeName, decl: AST::Declarations::Class | AST::Declarations::Module) -> void
131
+ end
132
+
133
+ class DuplicatedDeclarationError < StandardError
134
+ attr_reader name: TypeName | Symbol
135
+ attr_reader decls: Array[AST::Declarations::t]
136
+
137
+ def initialize: (TypeName | Symbol, *AST::Declarations::t) -> void
138
+ end
139
+
140
+ class InvalidVarianceAnnotationError < StandardError
141
+ attr_reader type_name: TypeName
142
+ attr_reader param: AST::Declarations::ModuleTypeParams::TypeParam
143
+ attr_reader location: Location?
144
+
145
+ def initialize: (type_name: TypeName, param: AST::Declarations::ModuleTypeParams::TypeParam, location: Location?) -> void
146
+ end
147
+
148
+ class RecursiveAliasDefinitionError < StandardError
149
+ type ty = Types::ClassInstance | Types::ClassSingleton | Types::Interface
150
+ type defn = DefinitionBuilder::MethodBuilder::Methods::Definition
151
+
152
+ attr_reader type: ty
153
+ attr_reader defs: Array[defn]
154
+
155
+ def initialize: (type: ty, defs: Array[defn]) -> void
156
+
157
+ def location: () -> Location?
158
+ end
20
159
  end
@@ -0,0 +1,71 @@
1
+ module RBS
2
+ class DefinitionBuilder
3
+ class MethodBuilder
4
+ class Methods
5
+ type instance_type = Types::ClassInstance | Types::ClassSingleton | Types::Interface
6
+
7
+ class Definition
8
+ type original = AST::Members::MethodDefinition | AST::Members::Alias | AST::Members::AttrAccessor | AST::Members::AttrWriter | AST::Members::AttrReader
9
+ type accessibility = :public | :private
10
+
11
+ attr_reader name: Symbol
12
+ attr_reader type: instance_type
13
+ attr_reader originals: Array[original]
14
+ attr_reader overloads: Array[AST::Members::MethodDefinition]
15
+ attr_reader accessibilities: Array[accessibility]
16
+
17
+ def initialize: (name: Symbol, type: instance_type, originals: Array[original], overloads: Array[AST::Members::MethodDefinition], accessibilities: Array[accessibility]) -> void
18
+
19
+ def original: () -> original?
20
+
21
+ def accessibility: () -> accessibility
22
+
23
+ def self.empty: (name: Symbol, type: instance_type) -> instance
24
+ end
25
+
26
+ attr_reader type: instance_type
27
+ attr_reader methods: Hash[Symbol, Definition]
28
+
29
+ def initialize: (type: instance_type) -> void
30
+
31
+ def validate!: () -> self
32
+
33
+ def each: () { (Definition) -> void } -> void
34
+ | () -> Enumerator[Definition, void]
35
+
36
+ class Sorter
37
+ include TSort[Definition]
38
+
39
+ attr_reader methods: Hash[Symbol, Definition]
40
+
41
+ def initialize: (Hash[Symbol, Definition]) -> void
42
+
43
+ def tsort_each_node: { (Definition) -> void } -> void
44
+
45
+ def tsort_each_child: (Definition) { (Definition) -> void } -> void
46
+ end
47
+ end
48
+
49
+ attr_reader env: Environment
50
+ attr_reader instance_methods: Hash[TypeName, Methods]
51
+ attr_reader singleton_methods: Hash[TypeName, Methods]
52
+ attr_reader interface_methods: Hash[TypeName, Methods]
53
+
54
+ def initialize: (env: Environment) -> void
55
+
56
+ def build_instance: (TypeName) -> Methods
57
+
58
+ def build_singleton: (TypeName) -> Methods
59
+
60
+ def build_interface: (TypeName) -> Methods
61
+
62
+ def build_alias: (Methods, Methods::instance_type, member: AST::Members::Alias, accessibility: Methods::Definition::accessibility) -> void
63
+
64
+ def build_attribute: (Methods, Methods::instance_type, member: AST::Members::AttrAccessor | AST::Members::AttrReader | AST::Members::AttrWriter, accessibility: Methods::Definition::accessibility) -> void
65
+
66
+ def build_method: (Methods, Methods::instance_type, member: AST::Members::MethodDefinition, accessibility: Methods::Definition::accessibility) -> void
67
+
68
+ def each_member_with_accessibility: (Array[AST::Members::t | AST::Declarations::t], ?accessibility: Definition::accessibility) { (AST::Members::t | AST::Declarations::t, Definition::accessibility) -> void } -> void
69
+ end
70
+ end
71
+ end
@@ -35,5 +35,8 @@ module RBS
35
35
 
36
36
  # Returns a substitution without variables given in `vars`.
37
37
  def without: (*Symbol vars) -> Substitution
38
+
39
+ # Returns true if given substitution is identity.
40
+ def empty?: () -> bool
38
41
  end
39
42
  end
@@ -115,7 +115,6 @@ module RBS
115
115
 
116
116
  class Variable
117
117
  attr_reader name: Symbol
118
- attr_reader location: Location?
119
118
 
120
119
  @@count: Integer
121
120
 
@@ -140,7 +139,6 @@ module RBS
140
139
 
141
140
  class ClassSingleton
142
141
  attr_reader name: TypeName
143
- attr_reader location: Location?
144
142
 
145
143
  include _TypeBase
146
144
 
@@ -178,8 +176,6 @@ module RBS
178
176
  class Interface
179
177
  include Application
180
178
 
181
- attr_reader location: Location?
182
-
183
179
  def initialize: (name: TypeName, args: Array[t], location: Location?) -> void
184
180
 
185
181
  include _TypeBase
@@ -194,15 +190,12 @@ module RBS
194
190
  class ClassInstance
195
191
  include Application
196
192
 
197
- attr_reader location: Location?
198
-
199
193
  def initialize: (name: TypeName, args: Array[t], location: Location?) -> void
200
194
 
201
195
  include _TypeBase
202
196
  end
203
197
 
204
198
  class Alias
205
- attr_reader location: Location?
206
199
  attr_reader name: TypeName
207
200
 
208
201
  def initialize: (name: TypeName, location: Location?) -> void
@@ -215,7 +208,6 @@ module RBS
215
208
 
216
209
  class Tuple
217
210
  attr_reader types: Array[t]
218
- attr_reader location: Location?
219
211
 
220
212
  def initialize: (types: Array[t], location: Location?) -> void
221
213
 
@@ -224,7 +216,6 @@ module RBS
224
216
 
225
217
  class Record
226
218
  attr_reader fields: Hash[Symbol, t]
227
- attr_reader location: Location?
228
219
 
229
220
  def initialize: (fields: Hash[Symbol, t], location: Location?) -> void
230
221
 
@@ -233,7 +224,6 @@ module RBS
233
224
 
234
225
  class Optional
235
226
  attr_reader type: t
236
- attr_reader location: Location?
237
227
 
238
228
  def initialize: (type: t, location: Location?) -> void
239
229
 
@@ -242,7 +232,6 @@ module RBS
242
232
 
243
233
  class Union
244
234
  attr_reader types: Array[t]
245
- attr_reader location: Location?
246
235
 
247
236
  def initialize: (types: Array[t], location: Location?) -> void
248
237
 
@@ -254,7 +243,6 @@ module RBS
254
243
 
255
244
  class Intersection
256
245
  attr_reader types: Array[t]
257
- attr_reader location: Location?
258
246
 
259
247
  def initialize: (types: Array[t], location: Location?) -> void
260
248
 
@@ -336,7 +324,7 @@ module RBS
336
324
 
337
325
  class Block
338
326
  attr_reader type: Types::Function
339
- attr_reader required: boolish
327
+ attr_reader required: bool
340
328
 
341
329
  def initialize: (type: Types::Function, required: boolish) -> void
342
330
 
@@ -352,7 +340,6 @@ module RBS
352
340
  class Proc
353
341
  attr_reader type: Function
354
342
  attr_reader block: Block?
355
- attr_reader location: Location?
356
343
 
357
344
  def initialize: (location: Location?, type: Function, block: Block?) -> void
358
345
 
@@ -363,7 +350,6 @@ module RBS
363
350
  type literal = String | Integer | Symbol | TrueClass | FalseClass
364
351
 
365
352
  attr_reader literal: literal
366
- attr_reader location: Location?
367
353
 
368
354
  def initialize: (literal: literal, location: Location?) -> void
369
355
 
@@ -160,6 +160,7 @@
160
160
  #
161
161
  class CSV < Object
162
162
  include Enumerable[untyped]
163
+ extend Forwardable
163
164
 
164
165
  # This method is intended as the primary interface for reading CSV files. You
165
166
  # pass a `path` and any `options` you wish to set for the read. Each row of file
@@ -408,6 +409,7 @@ CSV::VERSION: String
408
409
  #
409
410
  class CSV::Row < Object
410
411
  include Enumerable[untyped]
412
+ extend Forwardable
411
413
 
412
414
  # If a two-element Array is provided, it is assumed to be a header and field and
413
415
  # the pair is appended. A Hash works the same way with the key being the header
@@ -579,6 +581,7 @@ end
579
581
  #
580
582
  class CSV::Table[out Elem] < Object
581
583
  include Enumerable[untyped]
584
+ extend Forwardable
582
585
 
583
586
  # Constructs a new CSV::Table from `array_of_rows`, which are expected to be
584
587
  # CSV::Row objects. All rows are assumed to have the same headers.
@@ -373,7 +373,7 @@ class Pathname
373
373
  # Note that the results never contain the entries `.` and `..` in the directory
374
374
  # because they are not children.
375
375
  #
376
- def children: (?boolish with_directory) -> untyped
376
+ def children: (?boolish with_directory) -> Array[Pathname]
377
377
 
378
378
  # Changes file permissions.
379
379
  #
@@ -42,6 +42,12 @@
42
42
  #
43
43
  #
44
44
  class Prime
45
+ include Singleton
46
+
47
+ include Enumerable[Integer]
48
+
49
+ extend Enumerable[Integer]
50
+
45
51
  # Iterates the given block over all prime numbers.
46
52
  #
47
53
  # ## Parameters
@@ -1,4 +1,6 @@
1
1
  module SecureRandom
2
+ extend Random::Formatter
3
+
2
4
  def self.alphanumeric: (?Integer?) -> String
3
5
  def self.base64: (?Integer?) -> String
4
6
  def self.hex: (?Integer?) -> String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre
4
+ version: 1.0.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-19 00:00:00.000000000 Z
11
+ date: 2020-12-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -158,6 +158,7 @@ files:
158
158
  - schema/members.json
159
159
  - schema/methodType.json
160
160
  - schema/types.json
161
+ - sig/ancestor_builder.rbs
161
162
  - sig/annotation.rbs
162
163
  - sig/buffer.rbs
163
164
  - sig/builtin_names.rbs
@@ -173,6 +174,7 @@ files:
173
174
  - sig/errors.rbs
174
175
  - sig/location.rbs
175
176
  - sig/members.rbs
177
+ - sig/method_builder.rbs
176
178
  - sig/method_types.rbs
177
179
  - sig/namespace.rbs
178
180
  - sig/parser.rbs