steep 1.7.0.dev.3 → 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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +12 -12
  3. data/doc/narrowing.md +1 -1
  4. data/doc/shape.md +176 -0
  5. data/gemfile_steep/Gemfile.lock +5 -5
  6. data/lib/steep/ast/types/factory.rb +27 -18
  7. data/lib/steep/ast/types/proc.rb +14 -9
  8. data/lib/steep/interface/block.rb +1 -1
  9. data/lib/steep/interface/builder.rb +1 -0
  10. data/lib/steep/interface/function.rb +14 -6
  11. data/lib/steep/interface/method_type.rb +15 -7
  12. data/lib/steep/project/pattern.rb +1 -2
  13. data/lib/steep/server/interaction_worker.rb +6 -0
  14. data/lib/steep/server/lsp_formatter.rb +2 -0
  15. data/lib/steep/services/completion_provider.rb +1 -1
  16. data/lib/steep/services/file_loader.rb +15 -20
  17. data/lib/steep/services/signature_help_provider.rb +11 -9
  18. data/lib/steep/signature/validator.rb +1 -1
  19. data/lib/steep/subtyping/check.rb +15 -6
  20. data/lib/steep/subtyping/variable_variance.rb +3 -3
  21. data/lib/steep/type_construction.rb +185 -149
  22. data/lib/steep/type_inference/block_params.rb +1 -1
  23. data/lib/steep/type_inference/logic_type_interpreter.rb +2 -1
  24. data/lib/steep/type_inference/method_params.rb +16 -0
  25. data/lib/steep/type_inference/send_args.rb +5 -2
  26. data/lib/steep/version.rb +1 -1
  27. data/sig/steep/ast/types/factory.rbs +2 -2
  28. data/sig/steep/interface/builder.rbs +12 -53
  29. data/sig/steep/interface/function.rbs +5 -4
  30. data/sig/steep/services/signature_help_provider.rbs +1 -1
  31. data/sig/steep/subtyping/variable_variance.rbs +1 -1
  32. data/sig/steep/type_inference/block_params.rbs +1 -1
  33. data/sig/steep/type_inference/method_params.rbs +3 -3
  34. data/steep.gemspec +1 -1
  35. metadata +5 -4
@@ -46,8 +46,6 @@ module Steep
46
46
 
47
47
  def initialize: (AST::Types::Factory) -> void
48
48
 
49
- def fetch_cache: [KEY] (Hash[KEY, Shape?], KEY) { () -> Shape? } -> Shape?
50
-
51
49
  # Returns a shape of given type with respect to Config
52
50
  #
53
51
  # * If `self` occurs in the given type, it returns types with `self`
@@ -55,6 +53,10 @@ module Steep
55
53
  #
56
54
  def shape: (AST::Types::t, Config) -> Shape?
57
55
 
56
+ private
57
+
58
+ def fetch_cache: [KEY] (Hash[KEY, Shape?], KEY) { () -> Shape? } -> Shape?
59
+
58
60
  # Returns a shape of given type with respect to Config
59
61
  #
60
62
  # The `self` types included in the returned Shape is the `self` type in the top level
@@ -66,10 +68,16 @@ module Steep
66
68
 
67
69
  def self_shape: (AST::Types::t, Config) -> Shape?
68
70
 
69
- private
70
-
71
+ # Returns a shape of instance type and interface type
72
+ #
73
+ # The `self` types included in the shape is the `self` types in the definition.
74
+ #
71
75
  def object_shape: (RBS::TypeName) -> Shape
72
76
 
77
+ # Returns a shape of singleton type
78
+ #
79
+ # The `self` types included in the shape is the `self` types in the definition.
80
+ #
73
81
  def singleton_shape: (RBS::TypeName) -> Shape
74
82
 
75
83
  def union_shape: (AST::Types::t, Array[Shape]) -> Shape?
@@ -95,58 +103,9 @@ module Steep
95
103
 
96
104
  def replace_primitive_method: (method_name, RBS::Definition::Method::TypeDef, MethodType) -> MethodType
97
105
 
98
- # # Calculates the shape of given class, based on `public_only` and Config
99
- # #
100
- # # Returns `nil` if a type that cannot calculate Shape is given.
101
- # #
102
- # # * `public_only`: If false, returns a shape with private methods.
103
- # #
104
- # def shape: (AST::Types::t, public_only: bool, config: Config) -> Shape?
105
-
106
- # private
107
-
108
106
  @subtyping: Subtyping::Check?
109
107
 
110
108
  def subtyping: () -> Subtyping::Check
111
-
112
- # # Fetch and update cache
113
- # #
114
- # # Cache if given type is cacheable:
115
- # #
116
- # # * `self`, `instance`, `class` is not cacheable
117
- # # * Type variables are not cacheable
118
- # #
119
- # def fetch_cache: (AST::Types::t, bool public_only, Config) { () -> Shape? } -> Shape?
120
-
121
- # def include_self?: (AST::Types::t) -> bool
122
-
123
- # def definition_builder: () -> RBS::DefinitionBuilder
124
-
125
- # def object_shape: (
126
- # AST::Types::Name::Instance | AST::Types::Name::Singleton | AST::Types::Name::Interface,
127
- # bool public_only,
128
- # boolish keep_self,
129
- # boolish keep_instance,
130
- # boolish keep_singleton
131
- # ) -> Shape
132
-
133
- # def raw_object_shape: (
134
- # AST::Types::Name::Instance | AST::Types::Name::Singleton | AST::Types::Name::Interface,
135
- # bool public_only,
136
- # Substitution subst
137
- # ) -> Shape
138
-
139
- # def union_shape: (AST::Types::t, Array[Shape], bool public_only) -> Shape
140
-
141
- # def intersection_shape: (AST::Types::t, Array[Shape], bool public_only) -> Shape
142
-
143
- # def tuple_shape: (AST::Types::Tuple, bool public_only, Config) -> Shape
144
-
145
- # def record_shape: (AST::Types::Record, bool public_only, Config) -> Shape?
146
-
147
- # def proc_shape: (AST::Types::Proc, bool public_only, Config) -> Shape?
148
-
149
-
150
109
  end
151
110
  end
152
111
  end
@@ -177,7 +177,7 @@ module Steep
177
177
 
178
178
  def optional_keywords: () -> Hash[Symbol, AST::Types::t]
179
179
 
180
- def rest_keywords: () -> AST::Types::t?
180
+ %a{pure} def rest_keywords: () -> AST::Types::t?
181
181
 
182
182
  def has_keywords?: () -> bool
183
183
 
@@ -234,13 +234,14 @@ module Steep
234
234
 
235
235
  type location = RBS::Location[untyped, untyped]
236
236
 
237
- attr_reader params: Params
237
+ # Returns `nil` for `RBS::Types::UntypedFunction`
238
+ attr_reader params: Params?
238
239
 
239
240
  attr_reader return_type: AST::Types::t
240
241
 
241
242
  attr_reader location: location?
242
243
 
243
- 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
244
245
 
245
246
  def ==: (untyped other) -> bool
246
247
 
@@ -260,7 +261,7 @@ module Steep
260
261
 
261
262
  def map_type: () { (AST::Types::t) -> AST::Types::t } -> Function
262
263
 
263
- def with: (?params: Params, ?return_type: AST::Types::t) -> Function
264
+ def with: (?params: Params?, ?return_type: AST::Types::t) -> Function
264
265
 
265
266
  def to_s: () -> ::String
266
267
 
@@ -14,7 +14,7 @@ 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
20
  include Steep::NodeHelper
@@ -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
@@ -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]]
@@ -102,9 +102,9 @@ module Steep
102
102
  #
103
103
  # `nil` if the node doesn't have it.
104
104
  #
105
- attr_reader forward_arg_type: [Params, Block?]?
105
+ attr_reader forward_arg_type: [Params, Block?] | true | nil
106
106
 
107
- def initialize: (args: Array[Node], method_type: MethodType?, forward_arg_type: [Params, Block?]?) -> void
107
+ def initialize: (args: Array[Node], method_type: MethodType?, forward_arg_type: [Params, Block?] | true | nil) -> void
108
108
 
109
109
  def []: (Symbol name) -> param
110
110
 
@@ -117,7 +117,7 @@ module Steep
117
117
 
118
118
  def each: () { (Symbol, AST::Types::t) -> void } -> void
119
119
 
120
- def update: (?forward_arg_type: [Params, Block?]?) -> MethodParams
120
+ def update: (?forward_arg_type: [Params, Block?] | true | nil) -> MethodParams
121
121
 
122
122
  def self.empty: (node: Node) -> MethodParams
123
123
 
data/steep.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
34
34
  spec.add_runtime_dependency "listen", "~> 3.0"
35
35
  spec.add_runtime_dependency "language_server-protocol", ">= 3.15", "< 4.0"
36
- spec.add_runtime_dependency "rbs", ">= 3.1.0"
36
+ spec.add_runtime_dependency "rbs", ">= 3.5.0.pre"
37
37
  spec.add_runtime_dependency "concurrent-ruby", ">= 1.1.10"
38
38
  spec.add_runtime_dependency "terminal-table", ">= 2", "< 4"
39
39
  spec.add_runtime_dependency "securerandom", ">= 0.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steep
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0.dev.3
4
+ version: 1.7.0.dev.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-24 00:00:00.000000000 Z
11
+ date: 2024-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 3.1.0
101
+ version: 3.5.0.pre
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 3.1.0
108
+ version: 3.5.0.pre
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: concurrent-ruby
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -254,6 +254,7 @@ files:
254
254
  - bin/steep
255
255
  - bin/steep-prof
256
256
  - doc/narrowing.md
257
+ - doc/shape.md
257
258
  - exe/steep
258
259
  - gemfile_steep/Gemfile
259
260
  - gemfile_steep/Gemfile.lock