rbs 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/sig/types.rbs CHANGED
@@ -227,18 +227,21 @@ module RBS
227
227
  end
228
228
 
229
229
  class Alias
230
- attr_reader name: TypeName
230
+ # foo
231
+ # ^^^ => name
232
+ #
233
+ # foo[bar, baz]
234
+ # ^^^ => name
235
+ # ^^^^^^^^^^ => args
236
+ #
237
+ type loc = Location[:name, :args]
231
238
 
232
- type loc = Location[bot, bot]
239
+ attr_reader location: loc?
233
240
 
234
- def initialize: (name: TypeName, location: loc?) -> void
241
+ def initialize: (name: TypeName, args: Array[t], location: loc?) -> void
235
242
 
236
243
  include _TypeBase
237
- include NoFreeVariables
238
- include NoSubst
239
- include EmptyEachType
240
-
241
- attr_reader location: loc?
244
+ include Application
242
245
  end
243
246
 
244
247
  class Tuple
data/sig/validator.rbs CHANGED
@@ -1,8 +1,15 @@
1
1
  module RBS
2
2
  class Validator
3
3
  attr_reader env: Environment
4
+
4
5
  attr_reader resolver: TypeNameResolver
5
6
 
7
+ attr_reader definition_builder: DefinitionBuilder
8
+
9
+ attr_reader type_alias_dependency: TypeAliasDependency
10
+
11
+ attr_reader type_alias_regularity: TypeAliasRegularity
12
+
6
13
  def initialize: (env: Environment, resolver: TypeNameResolver) -> void
7
14
 
8
15
  def absolute_type: (Types::t, context: TypeNameResolver::context) { (Types::t) -> TypeName } -> Types::t
@@ -1,7 +1,47 @@
1
1
  module RBS
2
+ # Calculate the use variances of type variables in declaration.
3
+ #
4
+ # ```rb
5
+ # calculator = VarianceCalculator.new(builder: builder)
6
+ #
7
+ # # Calculates variances in a method type
8
+ # result = calculator.in_method_type(method_type: method_type, variables: variables)
9
+ #
10
+ # # Calculates variances in a inheritance/mixin/...
11
+ # result = calculator.in_inherit(name: name, args: args, variables: variables)
12
+ #
13
+ # # Calculates variances in a type alias
14
+ # result = calculator.in_type_alias(name: name, args: args, variables: variables)
15
+ # ```
16
+ #
17
+ # See `RBS::VarianceCaluculator::Result` for information recorded in the `Result` object.
18
+ #
2
19
  class VarianceCalculator
3
20
  type variance = :unused | :covariant | :contravariant | :invariant
4
21
 
22
+ # Result contains the set of type variables and it's variance in a occurrence.
23
+ #
24
+ # ```rb
25
+ # # Enumerates recorded type variables
26
+ # result.each do |name, variance|
27
+ # # name is the name of a type variable
28
+ # # variance is one of :unused | :covariant | :contravariant | :invariant
29
+ # end
30
+ # ```
31
+ #
32
+ # You can test with `compatible?` method if the type variable occurrences are compatible with specified (annotated) variance.
33
+ #
34
+ # ```rb
35
+ # # When T is declared as `out T`
36
+ # result.compatible?(:T, with_annotation: :covariant)
37
+ #
38
+ # # When T is declared as `in T`
39
+ # result.compatible?(:T, with_annotation: :contravariant)
40
+ #
41
+ # # When T is declared as `T`
42
+ # result.compatible?(:T, with_annotation: :invariant)
43
+ # ```
44
+ #
5
45
  class Result
6
46
  attr_reader result: Hash[Symbol, variance]
7
47
 
@@ -18,6 +58,8 @@ module RBS
18
58
  def include?: (Symbol) -> bool
19
59
 
20
60
  def compatible?: (Symbol, with_annotation: variance) -> bool
61
+
62
+ def incompatible?: (AST::Declarations::ModuleTypeParams) -> Set[Symbol]?
21
63
  end
22
64
 
23
65
  attr_reader builder: DefinitionBuilder
@@ -30,6 +72,14 @@ module RBS
30
72
 
31
73
  def in_inherit: (name: TypeName, args: Array[Types::t], variables: Array[Symbol]) -> Result
32
74
 
75
+ def in_type_alias: (name: TypeName) -> Result
76
+
77
+ private
78
+
33
79
  def type: (Types::t, result: Result, context: variance) -> void
80
+
81
+ def function: (Types::Function, result: Result, context: variance) -> void
82
+
83
+ def negate: (variance) -> variance
34
84
  end
35
85
  end
@@ -446,7 +446,7 @@ class Date
446
446
  # DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd
447
447
  # #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
448
448
  #
449
- def +: (Integer | Rational other) -> Date
449
+ def +: ((Numeric & _ToR) other) -> Date
450
450
 
451
451
  # Returns the difference between the two dates if the other is a date object.
452
452
  # If the other is a numeric value, returns a date object pointing `other` days
@@ -461,7 +461,7 @@ class Date
461
461
  # DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12)
462
462
  # #=> (1/2)
463
463
  #
464
- def -: (Integer | Rational other) -> Date
464
+ def -: ((Numeric & _ToR) other) -> Date
465
465
  | (Date other) -> Rational
466
466
 
467
467
  # Returns a date object pointing `n` months before self. The argument `n` should
data/stdlib/set/0/set.rbs CHANGED
@@ -122,7 +122,7 @@ class Set[A]
122
122
  #
123
123
  # See also Enumerable#include?
124
124
  #
125
- def include?: (untyped) -> bool
125
+ def include?: (A) -> bool
126
126
 
127
127
  alias member? include?
128
128
 
@@ -168,12 +168,12 @@ class Set[A]
168
168
  # Deletes the given object from the set and returns self. Use `subtract` to
169
169
  # delete many items at once.
170
170
  #
171
- def delete: (untyped) -> self
171
+ def delete: (A) -> self
172
172
 
173
173
  # Deletes the given object from the set and returns self. If the object is not
174
174
  # in the set, returns nil.
175
175
  #
176
- def delete?: (untyped) -> self?
176
+ def delete?: (A) -> self?
177
177
 
178
178
  # Deletes every element of the set for which block evaluates to true, and
179
179
  # returns self. Returns an enumerator if no block is given.
data/steep/Gemfile.lock CHANGED
@@ -9,37 +9,37 @@ GEM
9
9
  zeitwerk (~> 2.3)
10
10
  ast (2.4.2)
11
11
  concurrent-ruby (1.1.9)
12
- ffi (1.15.3)
13
- i18n (1.8.10)
12
+ ffi (1.15.4)
13
+ i18n (1.8.11)
14
14
  concurrent-ruby (~> 1.0)
15
15
  language_server-protocol (3.16.0.3)
16
16
  listen (3.7.0)
17
17
  rb-fsevent (~> 0.10, >= 0.10.3)
18
18
  rb-inotify (~> 0.9, >= 0.9.10)
19
19
  minitest (5.14.4)
20
- parallel (1.20.1)
21
- parser (3.0.2.0)
20
+ parallel (1.21.0)
21
+ parser (3.0.3.1)
22
22
  ast (~> 2.4.1)
23
23
  rainbow (3.0.0)
24
24
  rb-fsevent (0.11.0)
25
25
  rb-inotify (0.10.1)
26
26
  ffi (~> 1.0)
27
- rbs (1.5.1)
28
- steep (0.46.0)
27
+ rbs (1.7.1)
28
+ steep (0.47.0)
29
29
  activesupport (>= 5.1)
30
30
  language_server-protocol (>= 3.15, < 4.0)
31
31
  listen (~> 3.0)
32
32
  parallel (>= 1.0.0)
33
33
  parser (>= 3.0)
34
34
  rainbow (>= 2.2.2, < 4.0)
35
- rbs (>= 1.2.0)
35
+ rbs (~> 1.7.0)
36
36
  terminal-table (>= 2, < 4)
37
- terminal-table (3.0.1)
37
+ terminal-table (3.0.2)
38
38
  unicode-display_width (>= 1.1.1, < 3)
39
39
  tzinfo (2.0.4)
40
40
  concurrent-ruby (~> 1.0)
41
- unicode-display_width (2.0.0)
42
- zeitwerk (2.4.2)
41
+ unicode-display_width (2.1.0)
42
+ zeitwerk (2.5.1)
43
43
 
44
44
  PLATFORMS
45
45
  ruby
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.7.1
4
+ version: 1.8.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: 2021-11-18 00:00:00.000000000 Z
11
+ date: 2021-12-02 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.
@@ -174,6 +174,7 @@ files:
174
174
  - lib/rbs/test/tester.rb
175
175
  - lib/rbs/test/type_check.rb
176
176
  - lib/rbs/type_alias_dependency.rb
177
+ - lib/rbs/type_alias_regularity.rb
177
178
  - lib/rbs/type_name.rb
178
179
  - lib/rbs/type_name_resolver.rb
179
180
  - lib/rbs/types.rb
@@ -225,6 +226,7 @@ files:
225
226
  - sig/repository.rbs
226
227
  - sig/substitution.rbs
227
228
  - sig/type_alias_dependency.rbs
229
+ - sig/type_alias_regularity.rbs
228
230
  - sig/type_name_resolver.rbs
229
231
  - sig/typename.rbs
230
232
  - sig/types.rbs