steep 0.23.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/bin/smoke_runner.rb +3 -4
  4. data/lib/steep.rb +4 -3
  5. data/lib/steep/annotation_parser.rb +2 -4
  6. data/lib/steep/ast/builtin.rb +11 -21
  7. data/lib/steep/ast/types.rb +5 -3
  8. data/lib/steep/ast/types/any.rb +1 -3
  9. data/lib/steep/ast/types/boolean.rb +1 -3
  10. data/lib/steep/ast/types/bot.rb +1 -3
  11. data/lib/steep/ast/types/class.rb +2 -2
  12. data/lib/steep/ast/types/factory.rb +249 -89
  13. data/lib/steep/ast/types/helper.rb +6 -0
  14. data/lib/steep/ast/types/instance.rb +2 -2
  15. data/lib/steep/ast/types/intersection.rb +20 -13
  16. data/lib/steep/ast/types/literal.rb +1 -3
  17. data/lib/steep/ast/types/logic.rb +63 -0
  18. data/lib/steep/ast/types/name.rb +15 -67
  19. data/lib/steep/ast/types/nil.rb +1 -3
  20. data/lib/steep/ast/types/proc.rb +5 -2
  21. data/lib/steep/ast/types/record.rb +9 -4
  22. data/lib/steep/ast/types/self.rb +1 -1
  23. data/lib/steep/ast/types/top.rb +1 -3
  24. data/lib/steep/ast/types/tuple.rb +5 -3
  25. data/lib/steep/ast/types/union.rb +16 -9
  26. data/lib/steep/ast/types/var.rb +2 -2
  27. data/lib/steep/ast/types/void.rb +1 -3
  28. data/lib/steep/drivers/check.rb +4 -0
  29. data/lib/steep/errors.rb +14 -0
  30. data/lib/steep/interface/interface.rb +5 -62
  31. data/lib/steep/interface/method_type.rb +394 -93
  32. data/lib/steep/interface/substitution.rb +48 -6
  33. data/lib/steep/module_helper.rb +25 -0
  34. data/lib/steep/project/completion_provider.rb +48 -51
  35. data/lib/steep/project/file.rb +3 -3
  36. data/lib/steep/project/hover_content.rb +4 -6
  37. data/lib/steep/project/target.rb +5 -2
  38. data/lib/steep/server/base_worker.rb +5 -3
  39. data/lib/steep/server/code_worker.rb +2 -0
  40. data/lib/steep/server/master.rb +10 -1
  41. data/lib/steep/signature/validator.rb +3 -3
  42. data/lib/steep/source.rb +4 -3
  43. data/lib/steep/subtyping/check.rb +46 -59
  44. data/lib/steep/subtyping/constraints.rb +8 -0
  45. data/lib/steep/type_construction.rb +771 -513
  46. data/lib/steep/type_inference/block_params.rb +5 -0
  47. data/lib/steep/type_inference/constant_env.rb +3 -6
  48. data/lib/steep/type_inference/context.rb +8 -0
  49. data/lib/steep/type_inference/context_array.rb +4 -3
  50. data/lib/steep/type_inference/logic.rb +31 -0
  51. data/lib/steep/type_inference/logic_type_interpreter.rb +219 -0
  52. data/lib/steep/type_inference/type_env.rb +2 -2
  53. data/lib/steep/typing.rb +7 -0
  54. data/lib/steep/version.rb +1 -1
  55. data/smoke/alias/a.rb +1 -1
  56. data/smoke/case/a.rb +1 -1
  57. data/smoke/hash/d.rb +1 -1
  58. data/smoke/if/a.rb +1 -1
  59. data/smoke/module/a.rb +1 -1
  60. data/smoke/rescue/a.rb +4 -13
  61. data/smoke/type_case/a.rb +0 -7
  62. data/steep.gemspec +2 -2
  63. metadata +10 -10
  64. data/lib/steep/ast/method_type.rb +0 -126
  65. data/lib/steep/ast/namespace.rb +0 -80
  66. data/lib/steep/names.rb +0 -86
@@ -26,10 +26,3 @@ when String
26
26
  # @type var x: Integer
27
27
  x + 1
28
28
  end
29
-
30
- case x
31
- when Object
32
- # !expects@+2 IncompatibleTypeCase: var_name=x, ::Object <: (::Integer | ::String | ::Symbol)
33
- # !expects NoMethodError: type=::Object, method=foobar
34
- x.foobar
35
- end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "activesupport", ">= 5.1"
34
34
  spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
35
35
  spec.add_runtime_dependency "listen", "~> 3.1"
36
- spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0.2"
37
- spec.add_runtime_dependency "rbs", "~> 0.9.0"
36
+ spec.add_runtime_dependency "language_server-protocol", "~> 3.15.0.1"
37
+ spec.add_runtime_dependency "rbs", "~> 0.12.0"
38
38
  end
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: 0.23.0
4
+ version: 0.29.0
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-08-06 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 3.14.0.2
95
+ version: 3.15.0.1
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 3.14.0.2
102
+ version: 3.15.0.1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rbs
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 0.9.0
109
+ version: 0.12.0
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 0.9.0
116
+ version: 0.12.0
117
117
  description: Gradual Typing for Ruby
118
118
  email:
119
119
  - matsumoto@soutaro.com
@@ -143,8 +143,6 @@ files:
143
143
  - lib/steep/ast/buffer.rb
144
144
  - lib/steep/ast/builtin.rb
145
145
  - lib/steep/ast/location.rb
146
- - lib/steep/ast/method_type.rb
147
- - lib/steep/ast/namespace.rb
148
146
  - lib/steep/ast/type_params.rb
149
147
  - lib/steep/ast/types.rb
150
148
  - lib/steep/ast/types/any.rb
@@ -156,6 +154,7 @@ files:
156
154
  - lib/steep/ast/types/instance.rb
157
155
  - lib/steep/ast/types/intersection.rb
158
156
  - lib/steep/ast/types/literal.rb
157
+ - lib/steep/ast/types/logic.rb
159
158
  - lib/steep/ast/types/name.rb
160
159
  - lib/steep/ast/types/nil.rb
161
160
  - lib/steep/ast/types/proc.rb
@@ -184,7 +183,7 @@ files:
184
183
  - lib/steep/interface/method.rb
185
184
  - lib/steep/interface/method_type.rb
186
185
  - lib/steep/interface/substitution.rb
187
- - lib/steep/names.rb
186
+ - lib/steep/module_helper.rb
188
187
  - lib/steep/project.rb
189
188
  - lib/steep/project/completion_provider.rb
190
189
  - lib/steep/project/dsl.rb
@@ -218,6 +217,7 @@ files:
218
217
  - lib/steep/type_inference/context_array.rb
219
218
  - lib/steep/type_inference/local_variable_type_env.rb
220
219
  - lib/steep/type_inference/logic.rb
220
+ - lib/steep/type_inference/logic_type_interpreter.rb
221
221
  - lib/steep/type_inference/send_args.rb
222
222
  - lib/steep/type_inference/type_env.rb
223
223
  - lib/steep/typing.rb
@@ -374,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
374
374
  - !ruby/object:Gem::Version
375
375
  version: '0'
376
376
  requirements: []
377
- rubygems_version: 3.0.3
377
+ rubygems_version: 3.1.2
378
378
  signing_key:
379
379
  specification_version: 4
380
380
  summary: Gradual Typing for Ruby
@@ -1,126 +0,0 @@
1
- module Steep
2
- module AST
3
- class MethodType
4
- module Params
5
- class Base
6
- attr_reader :location
7
-
8
- def initialize(location:)
9
- @location = location
10
- end
11
-
12
- def update_location(location)
13
- dup.instance_eval do
14
- @location = location
15
- self
16
- end
17
- end
18
- end
19
-
20
- class Required < Base
21
- attr_reader :type
22
- attr_reader :next_params
23
-
24
- def initialize(location:, type:, next_params: nil)
25
- super(location: location)
26
- @type = type
27
- @next_params = next_params
28
- end
29
- end
30
-
31
- class Optional < Base
32
- attr_reader :type
33
- attr_reader :next_params
34
-
35
- def initialize(location:, type:, next_params: nil)
36
- super(location: location)
37
- @type = type
38
- @next_params = next_params
39
- end
40
- end
41
-
42
- class Rest < Base
43
- attr_reader :type
44
- attr_reader :next_params
45
-
46
- def initialize(location:, type:, next_params: nil)
47
- super(location: location)
48
- @type = type
49
- @next_params = next_params
50
- end
51
- end
52
-
53
- class RequiredKeyword < Base
54
- attr_reader :name
55
- attr_reader :type
56
- attr_reader :next_params
57
-
58
- def initialize(location:, name:, type:, next_params: nil)
59
- super(location: location)
60
- @name = name
61
- @type = type
62
- @next_params = next_params
63
- end
64
- end
65
-
66
- class OptionalKeyword < Base
67
- attr_reader :name
68
- attr_reader :type
69
- attr_reader :next_params
70
-
71
- def initialize(location:, name:, type:, next_params: nil)
72
- super(location: location)
73
- @name = name
74
- @type = type
75
- @next_params = next_params
76
- end
77
- end
78
-
79
- class RestKeyword < Base
80
- attr_reader :type
81
-
82
- def initialize(location:, type:)
83
- super(location: location)
84
- @type = type
85
- end
86
- end
87
- end
88
-
89
- class Block
90
- attr_reader :location
91
- attr_reader :params
92
- attr_reader :return_type
93
- attr_reader :optional
94
-
95
- def initialize(location:, params:, return_type:, optional:)
96
- @location = location
97
- @params = params
98
- @return_type = return_type
99
- @optional = optional
100
- end
101
- end
102
-
103
- attr_reader :location
104
- attr_reader :type_params
105
- attr_reader :params
106
- attr_reader :block
107
- attr_reader :return_type
108
-
109
- def initialize(location:, type_params:, params:, block:, return_type:)
110
- @location = location
111
- @type_params = type_params
112
- @params = params
113
- @block = block
114
- @return_type = return_type
115
- end
116
-
117
- class Super
118
- attr_reader :location
119
-
120
- def initialize(location:)
121
- @location = location
122
- end
123
- end
124
- end
125
- end
126
- end
@@ -1,80 +0,0 @@
1
- module Steep
2
- module AST
3
- class Namespace
4
- attr_reader :path
5
-
6
- def initialize(path:, absolute:)
7
- @path = path
8
- @absolute = absolute
9
- end
10
-
11
- def self.empty
12
- new(path: [], absolute: false)
13
- end
14
-
15
- def self.root
16
- new(path: [], absolute: true)
17
- end
18
-
19
- def +(other)
20
- if other.absolute?
21
- other
22
- else
23
- self.class.new(path: path + other.path, absolute: absolute?)
24
- end
25
- end
26
-
27
- def append(component)
28
- self.class.new(path: path + [component], absolute: absolute?)
29
- end
30
-
31
- def parent
32
- raise "Parent with empty namespace" if empty?
33
- self.class.new(path: path.take(path.size - 1), absolute: absolute?)
34
- end
35
-
36
- def absolute?
37
- @absolute
38
- end
39
-
40
- def relative?
41
- !absolute?
42
- end
43
-
44
- def absolute!
45
- self.class.new(path: path, absolute: true)
46
- end
47
-
48
- def empty?
49
- path.empty?
50
- end
51
-
52
- def ==(other)
53
- other.is_a?(Namespace) && other.path == path && other.absolute? == absolute?
54
- end
55
-
56
- alias eql? ==
57
-
58
- def hash
59
- self.class.hash ^ path.hash ^ absolute?.hash
60
- end
61
-
62
- def to_s
63
- if empty?
64
- absolute? ? "::" : ""
65
- else
66
- s = path.join("::")
67
- absolute? ? "::#{s}::" : "#{s}::"
68
- end
69
- end
70
-
71
- def self.parse(string)
72
- if string.start_with?("::")
73
- new(path: string.split("::").drop(1).map(&:to_sym), absolute: true)
74
- else
75
- new(path: string.split("::").map(&:to_sym), absolute: false)
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,86 +0,0 @@
1
- module Steep
2
- module Names
3
- class Base
4
- attr_reader :namespace
5
- attr_reader :name
6
- attr_reader :location
7
-
8
- def initialize(namespace:, name:, location: nil)
9
- @namespace = namespace
10
- @name = name
11
- @location = location
12
- end
13
-
14
- def absolute?
15
- namespace.absolute?
16
- end
17
-
18
- def relative?
19
- !absolute?
20
- end
21
-
22
- def ==(other)
23
- other.is_a?(self.class) && other.name == name && other.namespace == namespace
24
- end
25
-
26
- def hash
27
- self.class.hash ^ name.hash ^ namespace.hash
28
- end
29
-
30
- alias eql? ==
31
-
32
- def self.parse(string)
33
- namespace = AST::Namespace.parse(string.to_s)
34
- *_, name = namespace.path
35
- new(namespace: namespace.parent, name: name)
36
- end
37
-
38
- def absolute!
39
- self.class.new(namespace: namespace.absolute!,
40
- name: name)
41
- end
42
-
43
- def in_namespace(namespace)
44
- if absolute?
45
- self
46
- else
47
- self.class.new(namespace: namespace + self.namespace, name: name)
48
- end
49
- end
50
-
51
- def to_s
52
- "#{namespace}#{name}"
53
- end
54
- end
55
-
56
- class Module < Base
57
- def self.from_node(node)
58
- case node.type
59
- when :const, :casgn
60
- namespace = namespace_from_node(node.children[0]) or return
61
- name = node.children[1]
62
- new(namespace: namespace, name: name)
63
- end
64
- end
65
-
66
- def self.namespace_from_node(node)
67
- case node&.type
68
- when nil
69
- AST::Namespace.empty
70
- when :cbase
71
- AST::Namespace.root
72
- when :const
73
- namespace_from_node(node.children[0])&.yield_self do |parent|
74
- parent.append(node.children[1])
75
- end
76
- end
77
- end
78
- end
79
-
80
- class Interface < Base
81
- end
82
-
83
- class Alias < Base
84
- end
85
- end
86
- end