steep 1.7.0.dev.2 → 1.7.0.dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +17 -19
  3. data/doc/narrowing.md +1 -1
  4. data/doc/shape.md +176 -0
  5. data/gemfile_steep/Gemfile.lock +10 -12
  6. data/lib/steep/ast/types/factory.rb +27 -18
  7. data/lib/steep/ast/types/helper.rb +4 -0
  8. data/lib/steep/ast/types/intersection.rb +7 -0
  9. data/lib/steep/ast/types/proc.rb +14 -9
  10. data/lib/steep/ast/types/record.rb +7 -0
  11. data/lib/steep/ast/types/tuple.rb +7 -0
  12. data/lib/steep/ast/types/union.rb +7 -0
  13. data/lib/steep/drivers/stats.rb +2 -2
  14. data/lib/steep/drivers/validate.rb +4 -2
  15. data/lib/steep/expectations.rb +2 -2
  16. data/lib/steep/interface/block.rb +1 -1
  17. data/lib/steep/interface/builder.rb +337 -360
  18. data/lib/steep/interface/function.rb +82 -11
  19. data/lib/steep/interface/method_type.rb +18 -10
  20. data/lib/steep/interface/shape.rb +69 -18
  21. data/lib/steep/interface/substitution.rb +4 -0
  22. data/lib/steep/node_helper.rb +18 -1
  23. data/lib/steep/project/pattern.rb +1 -2
  24. data/lib/steep/server/interaction_worker.rb +6 -0
  25. data/lib/steep/server/lsp_formatter.rb +2 -0
  26. data/lib/steep/services/completion_provider.rb +20 -18
  27. data/lib/steep/services/file_loader.rb +15 -20
  28. data/lib/steep/services/signature_help_provider.rb +17 -18
  29. data/lib/steep/signature/validator.rb +1 -1
  30. data/lib/steep/subtyping/check.rb +19 -22
  31. data/lib/steep/subtyping/variable_variance.rb +3 -3
  32. data/lib/steep/test.rb +9 -0
  33. data/lib/steep/type_construction.rb +198 -158
  34. data/lib/steep/type_inference/block_params.rb +12 -4
  35. data/lib/steep/type_inference/context.rb +1 -1
  36. data/lib/steep/type_inference/logic_type_interpreter.rb +3 -2
  37. data/lib/steep/type_inference/method_params.rb +16 -0
  38. data/lib/steep/type_inference/send_args.rb +5 -2
  39. data/lib/steep/version.rb +1 -1
  40. data/lib/steep.rb +11 -7
  41. data/sig/steep/ast/types/factory.rbs +2 -2
  42. data/sig/steep/ast/types/helper.rbs +2 -0
  43. data/sig/steep/ast/types/intersection.rbs +2 -0
  44. data/sig/steep/ast/types/name.rbs +4 -0
  45. data/sig/steep/ast/types/record.rbs +2 -0
  46. data/sig/steep/ast/types/tuple.rbs +2 -0
  47. data/sig/steep/ast/types/union.rbs +2 -0
  48. data/sig/steep/expectations.rbs +1 -1
  49. data/sig/steep/interface/block.rbs +2 -2
  50. data/sig/steep/interface/builder.rbs +54 -109
  51. data/sig/steep/interface/function.rbs +38 -32
  52. data/sig/steep/interface/shape.rbs +23 -4
  53. data/sig/steep/interface/substitution.rbs +2 -0
  54. data/sig/steep/node_helper.rbs +11 -0
  55. data/sig/steep/services/signature_help_provider.rbs +3 -1
  56. data/sig/steep/subtyping/constraints.rbs +2 -2
  57. data/sig/steep/subtyping/variable_variance.rbs +1 -1
  58. data/sig/steep/type_construction.rbs +1 -1
  59. data/sig/steep/type_inference/block_params.rbs +3 -3
  60. data/sig/steep/type_inference/context.rbs +2 -0
  61. data/sig/steep/type_inference/method_params.rbs +3 -3
  62. data/sig/steep.rbs +1 -1
  63. data/steep.gemspec +1 -1
  64. metadata +6 -4
@@ -15,6 +15,8 @@ module Steep
15
15
  module NoChild
16
16
  def each_child: () { (t) -> void } -> void
17
17
  | () -> Enumerator[t, void]
18
+
19
+ def map_type: () { (t) -> t } -> self
18
20
  end
19
21
  end
20
22
  end
@@ -29,6 +29,8 @@ module Steep
29
29
  def each_child: () { (t) -> void } -> void
30
30
  | () -> Enumerator[t, void]
31
31
 
32
+ def map_type: () { (t) -> t } -> t
33
+
32
34
  def level: () -> Array[Integer]
33
35
 
34
36
  def with_location: (untyped new_location) -> Intersection
@@ -51,6 +51,7 @@ module Steep
51
51
  def map_type: () { (t) -> t } -> self
52
52
  end
53
53
 
54
+ # Singleton of a class/module
54
55
  class Singleton < Base
55
56
  def ==: (untyped other) -> bool
56
57
 
@@ -65,13 +66,16 @@ module Steep
65
66
  include Helper::NoChild
66
67
  end
67
68
 
69
+ # An instance of a class/module
68
70
  class Instance < Applying
69
71
  def to_module: () -> Singleton
70
72
  end
71
73
 
74
+ # An interface type
72
75
  class Interface < Applying
73
76
  end
74
77
 
78
+ # Type alias
75
79
  class Alias < Applying
76
80
  end
77
81
  end
@@ -28,6 +28,8 @@ module Steep
28
28
  def each_child: () { (t) -> void } -> void
29
29
  | () -> Enumerator[t, void]
30
30
 
31
+ def map_type: () { (t) -> t } -> Record
32
+
31
33
  def level: () -> Array[Integer]
32
34
 
33
35
  def with_location: (untyped new_location) -> Record
@@ -26,6 +26,8 @@ module Steep
26
26
  def each_child: () { (t) -> void } -> void
27
27
  | () -> Enumerator[t, void]
28
28
 
29
+ def map_type: () { (t) -> t } -> Tuple
30
+
29
31
  def level: () -> Array[Integer]
30
32
 
31
33
  def with_location: (untyped new_location) -> Tuple
@@ -27,6 +27,8 @@ module Steep
27
27
  def each_child: () { (t) -> void } -> void
28
28
  | () -> Enumerator[t, void]
29
29
 
30
+ def map_type: () { (t) -> t } -> t
31
+
30
32
  include Helper::ChildrenLevel
31
33
 
32
34
  def level: () -> Array[Integer]
@@ -19,7 +19,7 @@ module Steep
19
19
 
20
20
  def initialize: (start_position: position, end_position: position, severity: Steep::Diagnostic::LSPFormatter::severity, message: String, code: String) -> void
21
21
 
22
- def self.from_hash: (untyped) -> instance
22
+ def self.from_hash: (untyped) -> Diagnostic
23
23
 
24
24
  def self.from_lsp: (untyped) -> Diagnostic
25
25
 
@@ -25,9 +25,9 @@ module Steep
25
25
 
26
26
  def subst: (Substitution s) -> Block
27
27
 
28
- @fvs: Set[Symbol]
28
+ @fvs: Set[AST::Types::variable]
29
29
 
30
- def free_variables: () -> Set[Symbol]
30
+ def free_variables: () -> Set[AST::Types::variable]
31
31
 
32
32
  def to_s: () -> ::String
33
33
 
@@ -6,161 +6,106 @@ module Steep
6
6
  class Config
7
7
  # Type of `self` type included immediately in the type expression
8
8
  #
9
- attr_reader self_type: AST::Types::t
9
+ attr_reader self_type: AST::Types::t?
10
10
 
11
11
  # Type of `class` type included immediately in the type expression
12
12
  #
13
- attr_reader class_type: AST::Types::t | nil
13
+ attr_reader class_type: AST::Types::t?
14
14
 
15
15
  # Type of `instance` type included immediately in the type expression
16
16
  #
17
- attr_reader instance_type: AST::Types::t | nil
18
-
19
- # Resolves `self` types included in shape members
20
- #
21
- # * `false` only when the type expression is `self`
22
- #
23
- attr_reader resolve_self: bool
24
-
25
- # Resolves `class` types included in shape members
26
- #
27
- # * `false` only when the type expression is `class`
28
- #
29
- attr_reader resolve_class: bool
30
-
31
- # Resolves `instance` types included in shape members
32
- #
33
- # * `false` only when the type expression is `instance`
34
- #
35
- attr_reader resolve_instance: bool
17
+ attr_reader instance_type: AST::Types::t?
36
18
 
19
+ # Upper bounds of type variables
37
20
  attr_reader variable_bounds: Hash[Symbol, AST::Types::t?]
38
21
 
39
- def initialize: (
40
- self_type: AST::Types::t,
41
- class_type: AST::Types::t | nil,
42
- instance_type: AST::Types::t | nil,
43
- ?resolve_self: bool,
44
- ?resolve_class: bool,
45
- ?resolve_instance: bool,
46
- variable_bounds: Hash[Symbol, AST::Types::t?]
47
- ) -> void
22
+ def initialize: (self_type: AST::Types::t?, variable_bounds: Hash[Symbol, AST::Types::t?]) -> void
23
+ | (self_type: AST::Types::t?, class_type: AST::Types::t, instance_type: AST::Types::t, variable_bounds: Hash[Symbol, AST::Types::t?]) -> void
48
24
 
49
- def update: (
50
- ?self_type: AST::Types::t,
51
- ?class_type: AST::Types::t | nil,
52
- ?instance_type: AST::Types::t | nil,
53
- ?resolve_self: bool,
54
- ?resolve_class: bool,
55
- ?resolve_instance: bool,
56
- ?variable_bounds: Hash[Symbol, AST::Types::t?]
57
- ) -> self
25
+ def subst: () -> Substitution?
58
26
 
59
- @no_resolve: self?
60
- def no_resolve: () -> self
27
+ def self.empty: () -> Config
61
28
 
62
- def resolve?: () -> bool
29
+ def upper_bound: (Symbol) -> AST::Types::t?
63
30
 
64
- def ==: (untyped) -> bool
31
+ private
65
32
 
66
- alias eql? ==
33
+ def validate: () -> self
67
34
 
68
- def hash: () -> Integer
69
-
70
- @subst: Substitution
71
-
72
- # Substitution for immediate type expressions
73
- def subst: () -> Substitution
74
-
75
- # Returns `self_type`, or `nil` when it is `Types::Self`
76
- #
77
- def self_type?: () -> AST::Types::t?
78
-
79
- # Returns `class_type`, or `nil` when it is `Types::Class`
80
- #
81
- def class_type?: () -> AST::Types::t?
82
-
83
- # Returns `instanc_type`, or `nil` when it is `Types::Instance`
84
- #
85
- def instance_type?: () -> AST::Types::t?
35
+ def validate_fvs: (Symbol name, AST::Types::t?) -> void
86
36
  end
87
37
 
88
38
  attr_reader factory: AST::Types::Factory
89
39
 
90
- type cache_key = [
91
- AST::Types::t, # type
92
- bool, # public_only
93
- AST::Types::t | nil, # self_type
94
- AST::Types::t | nil, # class_type
95
- AST::Types::t | nil, # instance_type
96
- bool, bool, bool, # resolve_self, resolve_class, resolve_instance
97
- Hash[Symbol, AST::Types::t?]? # variable_bounds
98
- ]
99
- attr_reader cache: Hash[cache_key, Shape?]
40
+ # # No type application (if generic), no self-instance-module resolution
41
+ attr_reader object_shape_cache: Hash[TypeName, Shape?]
100
42
 
101
- # No type application (if generic), no self-instance-module resolution
102
- attr_reader raw_instance_object_shape_cache: Hash[[TypeName, bool], Shape]
43
+ attr_reader union_shape_cache: Hash[AST::Types::Union, Shape?]
103
44
 
104
- attr_reader raw_singleton_object_shape_cache: Hash[[TypeName, bool], Shape]
105
-
106
- attr_reader raw_interface_object_shape_cache: Hash[[TypeName, bool], Shape]
45
+ attr_reader singleton_shape_cache: Hash[TypeName, Shape?]
107
46
 
108
47
  def initialize: (AST::Types::Factory) -> void
109
48
 
110
- # Calculates the shape of given class, based on `public_only` and Config
111
- #
112
- # Returns `nil` if a type that cannot calculate Shape is given.
49
+ # Returns a shape of given type with respect to Config
113
50
  #
114
- # * `public_only`: If false, returns a shape with private methods.
51
+ # * If `self` occurs in the given type, it returns types with `self`
52
+ # * If `self` doesn't occur in the given type, it returns type withohut `self`, that is resolved to `config.self_type`
115
53
  #
116
- def shape: (AST::Types::t, public_only: bool, config: Config) -> Shape?
54
+ def shape: (AST::Types::t, Config) -> Shape?
117
55
 
118
56
  private
119
57
 
120
- @subtyping: Subtyping::Check?
58
+ def fetch_cache: [KEY] (Hash[KEY, Shape?], KEY) { () -> Shape? } -> Shape?
121
59
 
122
- def subtyping: () -> Subtyping::Check
60
+ # Returns a shape of given type with respect to Config
61
+ #
62
+ # The `self` types included in the returned Shape is the `self` type in the top level
63
+ #
64
+ # * `raw_shape(<self>)` -> may return a shape with `self`
65
+ # * `raw_shape(<Array[self]>) -> returns a shape that returns `self` from `#first` method
66
+ #
67
+ def raw_shape: (AST::Types::t, Config) -> Shape?
68
+
69
+ def self_shape: (AST::Types::t, Config) -> Shape?
123
70
 
124
- # Fetch and update cache
71
+ # Returns a shape of instance type and interface type
125
72
  #
126
- # Cache if given type is cacheable:
73
+ # The `self` types included in the shape is the `self` types in the definition.
127
74
  #
128
- # * `self`, `instance`, `class` is not cacheable
129
- # * Type variables are not cacheable
75
+ def object_shape: (RBS::TypeName) -> Shape
76
+
77
+ # Returns a shape of singleton type
78
+ #
79
+ # The `self` types included in the shape is the `self` types in the definition.
130
80
  #
131
- def fetch_cache: (AST::Types::t, bool public_only, Config) { () -> Shape? } -> Shape?
81
+ def singleton_shape: (RBS::TypeName) -> Shape
132
82
 
133
- def include_self?: (AST::Types::t) -> bool
83
+ def union_shape: (AST::Types::t, Array[Shape]) -> Shape?
134
84
 
135
- def definition_builder: () -> RBS::DefinitionBuilder
85
+ def intersection_shape: (AST::Types::t, Array[Shape]) -> Shape?
136
86
 
137
- def object_shape: (
138
- AST::Types::Name::Instance | AST::Types::Name::Singleton | AST::Types::Name::Interface,
139
- bool public_only,
140
- boolish keep_self,
141
- boolish keep_instance,
142
- boolish keep_singleton
143
- ) -> Shape
87
+ def proc_shape: (AST::Types::Proc, Shape) -> Shape
144
88
 
145
- def raw_object_shape: (
146
- AST::Types::Name::Instance | AST::Types::Name::Singleton | AST::Types::Name::Interface,
147
- bool public_only,
148
- Substitution subst
149
- ) -> Shape
89
+ def tuple_shape: (AST::Types::Tuple) { (AST::Types::Name::Instance) -> Shape? } -> Shape?
150
90
 
151
- def union_shape: (AST::Types::t, Array[Shape], bool public_only) -> Shape
91
+ def record_shape: (AST::Types::Record) { (AST::Types::Name::Instance) -> Shape? } -> Shape?
152
92
 
153
- def intersection_shape: (AST::Types::t, Array[Shape], bool public_only) -> Shape
93
+ # Substitution for `self`/`instance`/`class` types, built from the name of given type
94
+ #
95
+ def class_subst: (AST::Types::Name::Instance | AST::Types::Name::Singleton) -> Substitution
154
96
 
155
- def tuple_shape: (AST::Types::Tuple, bool public_only, Config) -> Shape
97
+ def interface_subst: (AST::Types::Name::Interface) -> Substitution
156
98
 
157
- def record_shape: (AST::Types::Record, bool public_only, Config) -> Shape?
99
+ # Substitution for type application of class instance, type alias, or interface types
100
+ def app_subst: (AST::Types::Name::Instance | AST::Types::Name::Alias | AST::Types::Name::Interface) -> Substitution
158
101
 
159
- def proc_shape: (AST::Types::Proc, bool public_only, Config) -> Shape?
102
+ def method_name_for: (RBS::Definition::Method::TypeDef, Symbol name) -> method_name
160
103
 
161
104
  def replace_primitive_method: (method_name, RBS::Definition::Method::TypeDef, MethodType) -> MethodType
162
105
 
163
- def method_name_for: (RBS::Definition::Method::TypeDef, Symbol name) -> method_name
106
+ @subtyping: Subtyping::Check?
107
+
108
+ def subtyping: () -> Subtyping::Check
164
109
  end
165
110
  end
166
111
  end
@@ -27,6 +27,7 @@ module Steep
27
27
  def var_type: () -> AST::Types::t
28
28
 
29
29
  def map_type: () { (AST::Types::t) -> AST::Types::t } -> self
30
+ | () -> Enumerator[AST::Types::t, void]
30
31
  end
31
32
 
32
33
  class Required < Base
@@ -57,6 +58,7 @@ module Steep
57
58
  def map: () { (param) -> param } -> PositionalParams
58
59
 
59
60
  def map_type: () { (AST::Types::t) -> AST::Types::t } -> PositionalParams
61
+ | () -> Enumerator[AST::Types::t, void]
60
62
 
61
63
  def subst: (Substitution s) -> PositionalParams
62
64
 
@@ -74,13 +76,13 @@ module Steep
74
76
 
75
77
  def size: () -> Integer
76
78
 
77
- def self.build: (required: Array[AST::Types::t], optional: Array[AST::Types::t], rest: AST::Types::t?) -> PositionalParams
79
+ def self.build: (required: Array[AST::Types::t], optional: Array[AST::Types::t], rest: AST::Types::t?) -> PositionalParams?
78
80
 
79
81
  extend Utils
80
82
 
81
83
  # Calculates xs + ys.
82
84
  # Never fails.
83
- def self.merge_for_overload: (PositionalParams? xs, PositionalParams? ys) -> PositionalParams
85
+ def self.merge_for_overload: (PositionalParams? xs, PositionalParams? ys) -> PositionalParams?
84
86
 
85
87
  # xs | ys
86
88
  def self.merge_for_union: (PositionalParams? xs, PositionalParams? ys) -> PositionalParams?
@@ -98,15 +100,15 @@ module Steep
98
100
 
99
101
  attr_reader rest: AST::Types::t?
100
102
 
101
- def initialize: (?requireds: ::Hash[untyped, untyped], ?optionals: ::Hash[untyped, untyped], ?rest: untyped?) -> void
103
+ def initialize: (?requireds: ::Hash[Symbol, AST::Types::t], ?optionals: ::Hash[Symbol, AST::Types::t], ?rest: AST::Types::t?) -> void
102
104
 
103
- def ==: (untyped other) -> untyped
105
+ def ==: (untyped other) -> bool
104
106
 
105
107
  alias eql? ==
106
108
 
107
- def hash: () -> untyped
109
+ def hash: () -> Integer
108
110
 
109
- def update: (?requireds: untyped, ?optionals: untyped, ?rest: untyped) -> untyped
111
+ def update: (?requireds: Hash[Symbol, AST::Types::t], ?optionals: Hash[Symbol, AST::Types::t], ?rest: AST::Types::t?) -> KeywordParams
110
112
 
111
113
  def empty?: () -> bool
112
114
 
@@ -117,6 +119,7 @@ module Steep
117
119
  | () -> Enumerator[AST::Types::t, void]
118
120
 
119
121
  def map_type: () { (AST::Types::t) -> AST::Types::t } -> KeywordParams
122
+ | () -> Enumerator[AST::Types::t, KeywordParams]
120
123
 
121
124
  def subst: (Substitution s) -> KeywordParams
122
125
 
@@ -127,13 +130,13 @@ module Steep
127
130
  include Utils
128
131
 
129
132
  # For overloading
130
- def +: (untyped other) -> untyped
133
+ def +: (KeywordParams other) -> KeywordParams
131
134
 
132
135
  # For union
133
- def |: (untyped other) -> untyped
136
+ def |: (KeywordParams other) -> KeywordParams
134
137
 
135
138
  # For intersection
136
- def &: (untyped other) -> (nil | untyped)
139
+ def &: (KeywordParams other) -> KeywordParams?
137
140
  end
138
141
 
139
142
  def required: () -> Array[AST::Types::t]
@@ -146,54 +149,55 @@ module Steep
146
149
 
147
150
  attr_reader keyword_params: KeywordParams
148
151
 
149
- def self.build: (?required: untyped, ?optional: untyped, ?rest: untyped?, ?required_keywords: ::Hash[untyped, untyped], ?optional_keywords: ::Hash[untyped, untyped], ?rest_keywords: untyped?) -> untyped
152
+ def self.build: (?required: Array[AST::Types::t], ?optional: Array[AST::Types::t], ?rest: AST::Types::t?, ?required_keywords: ::Hash[Symbol, AST::Types::t], ?optional_keywords: ::Hash[Symbol, AST::Types::t], ?rest_keywords: AST::Types::t?) -> Params
150
153
 
151
- def initialize: (positional_params: untyped, keyword_params: untyped) -> void
154
+ def initialize: (positional_params: PositionalParams?, keyword_params: KeywordParams) -> void
152
155
 
153
- def update: (?positional_params: untyped, ?keyword_params: untyped) -> untyped
156
+ def update: (?positional_params: PositionalParams?, ?keyword_params: KeywordParams) -> Params
154
157
 
155
- def first_param: () -> untyped
158
+ def first_param: () -> PositionalParams::param?
156
159
 
157
- def with_first_param: (untyped param) -> untyped
160
+ def with_first_param: (PositionalParams::param) -> Params
158
161
 
159
- def has_positional?: () -> (true | false)
162
+ def has_positional?: () -> bool
160
163
 
161
- def self.empty: () -> untyped
164
+ def self.empty: () -> Params
162
165
 
163
- def ==: (untyped other) -> untyped
166
+ def ==: (untyped other) -> bool
164
167
 
165
168
  alias eql? ==
166
169
 
167
- def hash: () -> untyped
170
+ def hash: () -> Integer
168
171
 
169
172
  def flat_unnamed_params: () -> Array[[:required | :optional, AST::Types::t]]
170
173
 
171
- def flat_keywords: () -> untyped
174
+ def flat_keywords: () -> Hash[Symbol, AST::Types::t]
172
175
 
173
- def required_keywords: () -> untyped
176
+ def required_keywords: () -> Hash[Symbol, AST::Types::t]
174
177
 
175
- def optional_keywords: () -> untyped
178
+ def optional_keywords: () -> Hash[Symbol, AST::Types::t]
176
179
 
177
- def rest_keywords: () -> untyped
180
+ %a{pure} def rest_keywords: () -> AST::Types::t?
178
181
 
179
- def has_keywords?: () -> untyped
182
+ def has_keywords?: () -> bool
180
183
 
181
184
  def each_positional_param: () { (PositionalParams::Base) -> void } -> void
182
185
 
183
- def without_keywords: () -> untyped
186
+ def without_keywords: () -> Params
184
187
 
185
- def drop_first: () -> untyped
188
+ def drop_first: () -> Params
186
189
 
187
190
  def each_type: () { (AST::Types::t) -> void } -> void
188
191
  | () -> Enumerator[AST::Types::t, void]
189
192
 
190
- def free_variables: () -> untyped
193
+ @fvs: Set[AST::Types::variable]?
194
+ def free_variables: () -> Set[AST::Types::variable]
191
195
 
192
- def closed?: () -> untyped
196
+ def closed?: () -> bool
193
197
 
194
198
  def subst: (Substitution s) -> Params
195
199
 
196
- def size: () -> untyped
200
+ def size: () -> Integer
197
201
 
198
202
  def to_s: () -> ::String
199
203
 
@@ -230,13 +234,14 @@ module Steep
230
234
 
231
235
  type location = RBS::Location[untyped, untyped]
232
236
 
233
- attr_reader params: Params
237
+ # Returns `nil` for `RBS::Types::UntypedFunction`
238
+ attr_reader params: Params?
234
239
 
235
240
  attr_reader return_type: AST::Types::t
236
241
 
237
242
  attr_reader location: location?
238
243
 
239
- def initialize: (params: Params, return_type: AST::Types::t, location: location?) -> void
244
+ def initialize: (params: Params?, return_type: AST::Types::t, location: location?) -> void
240
245
 
241
246
  def ==: (untyped other) -> bool
242
247
 
@@ -244,7 +249,8 @@ module Steep
244
249
 
245
250
  def hash: () -> Integer
246
251
 
247
- def free_variables: () -> Set[Symbol]
252
+ @fvs: Set[AST::Types::variable]?
253
+ def free_variables: () -> Set[AST::Types::variable]
248
254
 
249
255
  def subst: (Substitution s) -> Function
250
256
 
@@ -255,7 +261,7 @@ module Steep
255
261
 
256
262
  def map_type: () { (AST::Types::t) -> AST::Types::t } -> Function
257
263
 
258
- def with: (?params: Params, ?return_type: AST::Types::t) -> Function
264
+ def with: (?params: Params?, ?return_type: AST::Types::t) -> Function
259
265
 
260
266
  def to_s: () -> ::String
261
267
 
@@ -2,11 +2,26 @@ module Steep
2
2
  module Interface
3
3
  class Shape
4
4
  class Entry
5
- attr_reader method_types: Array[MethodType]
5
+ @private_method: bool
6
6
 
7
- def initialize: (method_types: Array[MethodType]) -> void
7
+ @method_types: Array[MethodType]?
8
+
9
+ @generator: (^() -> Array[MethodType]?)?
10
+
11
+ def initialize: (method_types: Array[MethodType], private_method: bool) -> void
12
+ | (private_method: bool) { () -> Array[MethodType]? } -> void
13
+
14
+ def has_method_type?: () -> bool
8
15
 
9
16
  def to_s: () -> String
17
+
18
+ def private_method?: () -> bool
19
+
20
+ def public_method?: () -> bool
21
+
22
+ def method_types: () -> Array[MethodType]
23
+
24
+ def force: () -> void
10
25
  end
11
26
 
12
27
  class Methods
@@ -36,9 +51,9 @@ module Steep
36
51
 
37
52
  def push_substitution: (Substitution) -> Methods
38
53
 
39
- def merge!: (Methods other) -> void
54
+ def merge!: (Methods other) ?{ (Symbol name, Entry old_entry, Entry new_entry) -> Entry } -> void
40
55
 
41
- # def +: (Methods other) -> Methods
56
+ def public_methods: () -> Methods
42
57
  end
43
58
 
44
59
  attr_reader type: AST::Types::t
@@ -56,6 +71,10 @@ module Steep
56
71
  def public?: () -> bool
57
72
 
58
73
  def subst: (Substitution, ?type: AST::Types::t?) -> Shape
74
+
75
+ def public_shape: () -> Shape
76
+
77
+ @public_shape: Shape?
59
78
  end
60
79
  end
61
80
  end
@@ -41,6 +41,8 @@ module Steep
41
41
 
42
42
  def merge: (Substitution s) -> Substitution
43
43
 
44
+ def update: (?self_type: AST::Types::t?, ?instance_type: AST::Types::t?, ?module_type: AST::Types::t?) -> Substitution
45
+
44
46
  def apply?: (AST::Types::t) -> bool
45
47
 
46
48
  def add!: (Symbol v, AST::Types::t ty) -> self
@@ -66,6 +66,17 @@ module Steep
66
66
 
67
67
  def test_send_node: (Node) { (Node?, Symbol, Array[Node], send_loc) -> bool } -> bool
68
68
 
69
+ # Returns if given node allows calling private method
70
+ #
71
+ # The node must be:
72
+ #
73
+ # * A `send` node,
74
+ # * A `csend` node,
75
+ # * A `block` node, or
76
+ # * A `nblock` node
77
+ #
78
+ def private_send?: (Node) -> bool
79
+
69
80
  # Deconstruct sendish node and it's associated block node
70
81
  #
71
82
  # Receives a sequence of node tree where the leaf node comes first.
@@ -14,9 +14,11 @@ module Steep
14
14
 
15
15
  def initialize: (RBS::MethodType, RBS::AST::Comment?, Integer?) -> void
16
16
 
17
- def parameters: () -> Array[String]
17
+ def parameters: () -> Array[String]?
18
18
  end
19
19
 
20
+ include Steep::NodeHelper
21
+
20
22
  attr_reader source: Source
21
23
 
22
24
  attr_reader path: Pathname
@@ -91,8 +91,8 @@ module Steep
91
91
 
92
92
  def lower_bound: (Symbol var, ?skip: bool) -> AST::Types::t
93
93
 
94
- def solution: (Check checker, variables: Enumerable[Symbol], variance: VariableVariance, self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t) -> Interface::Substitution
95
- | (Check checker, variables: Enumerable[Symbol], context: Context) -> Interface::Substitution
94
+ def solution: (Check checker, variables: Enumerable[AST::Types::variable], variance: VariableVariance, self_type: AST::Types::t, instance_type: AST::Types::t, class_type: AST::Types::t) -> Interface::Substitution
95
+ | (Check checker, variables: Enumerable[AST::Types::variable], context: Context) -> Interface::Substitution
96
96
 
97
97
  def has_constraint?: (Symbol var) -> bool
98
98
 
@@ -17,7 +17,7 @@ module Steep
17
17
 
18
18
  def self.from_method_type: (Interface::MethodType method_type) -> VariableVariance
19
19
 
20
- def self.add_params: (Interface::Function::Params params, block: bool, covariants: Set[Symbol], contravariants: Set[Symbol]) -> void
20
+ def self.add_params: (Interface::Function::Params? params, block: bool, covariants: Set[Symbol], contravariants: Set[Symbol]) -> void
21
21
 
22
22
  def self.add_type: (AST::Types::t `type`, variance: :covariant | :contravariant | :invariant, covariants: Set[Symbol], contravariants: Set[Symbol]) -> void
23
23
  end
@@ -325,7 +325,7 @@ module Steep
325
325
  def set_up_block_mlhs_params_env: (
326
326
  Parser::AST::Node mlhs_node,
327
327
  AST::Types::t type,
328
- Hash[Symbol, AST::Types::t]
328
+ Hash[Symbol?, AST::Types::t]
329
329
  ) { (Parser::AST::Node error_mlhs_node, AST::Types::t type) -> void } -> void
330
330
 
331
331
  # Returns a Pair of
@@ -37,7 +37,7 @@ module Steep
37
37
  # * `node` is the node of the parameter
38
38
  #
39
39
  class Param
40
- attr_reader var: Symbol
40
+ attr_reader var: Symbol?
41
41
 
42
42
  attr_reader type: AST::Types::t?
43
43
 
@@ -45,7 +45,7 @@ module Steep
45
45
 
46
46
  attr_reader node: Parser::AST::Node
47
47
 
48
- def initialize: (var: Symbol, type: AST::Types::t?, value: Parser::AST::Node?, node: Parser::AST::Node) -> void
48
+ def initialize: (var: Symbol?, type: AST::Types::t?, value: Parser::AST::Node?, node: Parser::AST::Node) -> void
49
49
 
50
50
  def ==: (untyped other) -> bool
51
51
 
@@ -127,7 +127,7 @@ module Steep
127
127
  | (hint: Interface::Function::Params?) -> Interface::Function::Params?
128
128
 
129
129
  def zip: (
130
- Interface::Function::Params params_type,
130
+ Interface::Function::Params? params_type,
131
131
  Interface::Block? block,
132
132
  factory: AST::Types::Factory
133
133
  ) -> Array[[Param | MultipleParam, AST::Types::t]]
@@ -147,6 +147,8 @@ module Steep
147
147
  # Returns the upper bound of a type variable
148
148
  def []: (Symbol name) -> AST::Types::t?
149
149
 
150
+ @upper_bounds: Hash[Symbol, AST::Types::t]?
151
+
150
152
  def upper_bounds: () -> Hash[Symbol, AST::Types::t]
151
153
 
152
154
  def self.empty: () -> TypeVariableContext