raap 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e99f2314c4dda64e47604310a13a5814b1fe016f1e54a73e4531d9fcae504325
4
- data.tar.gz: 11698fd1846523fb0d17bcc7d38f5d115ddbffa590aee182977d11e2702b8b7d
3
+ metadata.gz: 11be72cf2761c092ecbbcb59c5fd6d63de28d5c469b08595788cd62d27ba65c3
4
+ data.tar.gz: 2dc754b684cca3752177f0a5d1ef12ae3126d6ae7b32e07664e639fa27037f8a
5
5
  SHA512:
6
- metadata.gz: ee00fb743ee63fcdc1cfb2b3301e4cc911b705b65d43b1018b1cccdfe64d486887895491a1b7dbf64d1c01ace851eb8f1f4ea2fe8c6f375e915e322b0afd3c33
7
- data.tar.gz: 45352b27b3bb0d3dae3b31ee02a12a1e61124d854fbe9539fd0726cbc7baeb17307fbfee67591aec1269690168dc94b8666d7f1ec67c2f52abe0bf87ad84e902
6
+ metadata.gz: 8dcca8c7c5aa10b0cd611a60c38a84bf4db1915cd049d701f068836488b748b653bd0a811d606c943754c0b4e72367d8e9255c06cdf0ab0f398bd3da3ce5357e
7
+ data.tar.gz: 3f2e7d3947ed5fbc02496b0f5437d100d6e6ba9cf8fd60c28b522d49f867c955b72a287d1845186346a377047acfed7d9944e6ef80d0dec1491235c3da9bf203
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0] - 2024-08-23
4
+
5
+ * Do not modify array for RBS::Types::ClassInstance#args by @pocke in https://github.com/ksss/raap/pull/25
6
+
3
7
  ## [0.10.0] - 2024-06-25
4
8
 
5
9
  * Support default nil in block by @ksss in https://github.com/ksss/raap/pull/18
data/lib/raap/coverage.rb CHANGED
@@ -83,7 +83,8 @@ module RaaP
83
83
  @cur = type.location.start_pos
84
84
  case type
85
85
  when ::RBS::Types::Tuple, ::RBS::Types::Union
86
- name = type.class.name.split('::').last.downcase
86
+ cname = type.class.name or raise
87
+ name = cname.split('::').last.downcase
87
88
  type.types.each_with_index do |t, i|
88
89
  t.location or raise
89
90
  io.write(slice(@cur, @cur...t.location.start_pos)) # ( or [
@@ -43,7 +43,7 @@ module RaaP
43
43
  build_type_with_coverage("opt_#{i}", param)
44
44
  end
45
45
 
46
- rest = []
46
+ rest = [] #: Array[untyped]
47
47
  if (rest_param = @fun.rest_positionals)
48
48
  rest = Array.new(Random.rand(4)) do
49
49
  build_type_with_coverage("rest", rest_param)
@@ -48,8 +48,8 @@ module RaaP
48
48
  return nil if block.nil?
49
49
  return nil if (block.required == false) && [true, false].sample
50
50
 
51
- args_name = []
52
- args_source = []
51
+ args_name = [] #: Array[String]
52
+ args_source = [] #: Array[String]
53
53
  resource = [*'a'..'z']
54
54
  case fun = block.type
55
55
  when ::RBS::Types::Function
@@ -51,7 +51,7 @@ module RaaP
51
51
  receiver = try_eval(receiver)
52
52
  args, kwargs, block = try_eval([args, kwargs, block])
53
53
 
54
- a = []
54
+ a = [] #: Array[String]
55
55
  a << args.map(&BindCall.method(:inspect)).join(', ') if !args.empty?
56
56
  a << kwargs.map { |k, v| "#{k}: #{BindCall.inspect(v)}" }.join(', ') if !kwargs.empty?
57
57
  argument_str = a.join(', ')
@@ -87,7 +87,7 @@ module RaaP
87
87
 
88
88
  var_eq = '' if is_last
89
89
 
90
- arguments = []
90
+ arguments = [] #: Array[Array[String]]
91
91
  if !args.empty?
92
92
  # The reproduction code is kept short and executable.
93
93
  if [Value::Interface, Value::Intersection].include?(receiver_value)
@@ -12,8 +12,8 @@ module RaaP
12
12
  self_type = type
13
13
 
14
14
  # Referring to Steep
15
- instance_type = ::RBS::Types::ClassInstance.new(name: TypeName("::Object"), args: [], location: nil)
16
- class_type = ::RBS::Types::ClassSingleton.new(name: TypeName("::Object"), location: nil)
15
+ instance_type = ::RBS::Types::ClassInstance.new(name: ::RBS::TypeName.parse("::Object"), args: [], location: nil)
16
+ class_type = ::RBS::Types::ClassSingleton.new(name: ::RBS::TypeName.parse("::Object"), location: nil)
17
17
 
18
18
  definition = RBS.builder.build_interface(type.name.absolute!)
19
19
  definition.methods.each do |name, method|
@@ -23,7 +23,7 @@ module RaaP
23
23
  subed_method_type = ts.method_type_sub(method_type, self_type: self_type, instance_type: instance_type, class_type: class_type)
24
24
 
25
25
  BindCall.define_method(base_mod, name) do |*_, &b|
26
- @fixed_return_value ||= {}
26
+ @fixed_return_value ||= {} #: Hash[Symbol, Interface | Type]
27
27
  @fixed_return_value[name] ||= if self_type == subed_method_type.type.return_type
28
28
  self
29
29
  else
@@ -31,7 +31,7 @@ module RaaP
31
31
  end
32
32
  # @type var b: Proc?
33
33
  if b && subed_method_type.block && subed_method_type.block.type.is_a?(::RBS::Types::Function)
34
- @fixed_block_arguments ||= {}
34
+ @fixed_block_arguments ||= {} #: Hash[Symbol, Array[FunctionType]]
35
35
  @fixed_block_arguments[name] ||= size.times.map do
36
36
  FunctionType.new(subed_method_type.block.type, coverage: false)
37
37
  .pick_arguments(size: size)
@@ -31,7 +31,7 @@ module RaaP
31
31
  end
32
32
  end
33
33
  end
34
- type = ::RBS::Types::ClassInstance.new(name: TypeName(base.name), args: [], location: nil)
34
+ type = ::RBS::Types::ClassInstance.new(name: ::RBS::TypeName.parse(base.name), args: [], location: nil)
35
35
  SymbolicCaller.new(Type.call_new_from(c, type, size: size)).eval
36
36
  end
37
37
  end
@@ -11,6 +11,7 @@ module RaaP
11
11
  # @type var type: String | Symbol
12
12
  ::RBS::Types::Variable.new(name: type.to_sym, location: nil)
13
13
  else
14
+ # @type var type: ::RBS::Types::Variable
14
15
  type
15
16
  end
16
17
  unless @type.instance_of?(::RBS::Types::Variable)
data/lib/raap/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RaaP
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0"
5
5
  end
data/lib/shims.rb CHANGED
@@ -36,3 +36,22 @@ unless defined?(Data)
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ # RBS 3.8
41
+ unless RBS::TypeName.singleton_class.method_defined?(:parse)
42
+ module RBS
43
+ class TypeName
44
+ def self.parse(string)
45
+ absolute = string.start_with?("::")
46
+
47
+ *path, name = string.delete_prefix("::").split("::").map(&:to_sym)
48
+ raise unless name
49
+
50
+ TypeName.new(
51
+ name: name,
52
+ namespace: RBS::Namespace.new(path: path, absolute: absolute)
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-23 00:00:00.000000000 Z
11
+ date: 2025-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.3.26
98
+ rubygems_version: 3.5.22
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: RBS as a Property