rbs 0.2.0 → 0.3.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: 2559e695400fc8d1c360aa80b1a9065f5ea0ae24b59faa91907102f7fc46d572
4
- data.tar.gz: e32722dcf716317553827e15b3232e8971f3d613c3b2bd7f71a5b902e2fef8b3
3
+ metadata.gz: 8ffec56ef44262c857185b7700f17f586b8e1e857776eedc75663a0021246f2e
4
+ data.tar.gz: 53cf7480a2793dd8228cd385c40d10e767b7cb32d0216c302b8aee7c21423d3c
5
5
  SHA512:
6
- metadata.gz: c26e77f6a2506cf1414d12aa74e1783bf8f7ca40d5e803831c9deb2e8b290954db119bb89fa8d26a24b76e8713b26fdd6535e557e59788808addbc3e96a07ec8
7
- data.tar.gz: 10a1e4a16e16f627bda62c565258b84bb830c7a85b0d74acbd9187094626b3e76eca4f8bacc5d77758755bfa82d5dacdd7dc6a374b53f3778d0421b449013d40
6
+ metadata.gz: fa78c2ec3746d5803709fc999737d29d5bb072cddc6ad1b3af94d25bf3f3aa24b61051a1e3753095f30393fd7378fc88420d05a8bb6fdea38ca355072f8c3ebc
7
+ data.tar.gz: bd355d3d6b3e8df2fb6e06608aaa3d12182c1e3a6d5add565c1f98032faa65c8d003d3e13ce409d22767b1cb64ad0964501cb68801488a5c4c1db01b8e075bca
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.3.0 (2020-05-20)
6
+
7
+ * Fix constant resolution [#288](https://github.com/ruby/rbs/pull/288)
8
+
9
+ ## 0.2.0
10
+
5
11
  * The first release of RBS gem.
6
12
 
7
13
  ## 0.1.0
@@ -362,7 +362,7 @@ module RBS
362
362
  name = Namespace.parse(args[0]).to_type_name
363
363
  stdout.puts "Constant name: #{name}"
364
364
 
365
- constant = table.resolve_constant_reference(name, context: namespace)
365
+ constant = table.resolve_constant_reference(name, context: namespace.ascend.to_a)
366
366
 
367
367
  if constant
368
368
  stdout.puts " => #{constant.name}: #{constant.type}"
@@ -30,17 +30,18 @@ module RBS
30
30
  end
31
31
 
32
32
  def resolve_constant_reference(name, context:)
33
+ raise "Context cannot be empty: Specify `[Namespace.root]`" if context.empty?
34
+
33
35
  head, *tail = split_name(name)
34
36
 
35
37
  head_constant = case
36
38
  when name.absolute?
37
39
  name_to_constant(TypeName.new(name: head, namespace: Namespace.root))
38
- when !context || context.empty?
40
+ when context == [Namespace.root]
39
41
  name_to_constant(TypeName.new(name: head, namespace: Namespace.root))
40
42
  else
41
43
  resolve_constant_reference_context(head, context: context) ||
42
- resolve_constant_reference_inherit(head,
43
- scopes: constant_scopes(context.to_type_name))
44
+ resolve_constant_reference_inherit(head, scopes: constant_scopes(context.first.to_type_name))
44
45
  end
45
46
 
46
47
  if head_constant
@@ -53,11 +54,11 @@ module RBS
53
54
  end
54
55
 
55
56
  def resolve_constant_reference_context(name, context:)
56
- if context.empty?
57
- nil
58
- else
59
- name_to_constant(TypeName.new(name: name, namespace: context)) ||
60
- resolve_constant_reference_context(name, context: context.parent)
57
+ head, *tail = context
58
+
59
+ if head
60
+ name_to_constant(TypeName.new(name: name, namespace: head)) ||
61
+ resolve_constant_reference_context(name, context: tail)
61
62
  end
62
63
  end
63
64
 
@@ -125,7 +126,7 @@ module RBS
125
126
 
126
127
  scopes.unshift namespace
127
128
  else
128
- raise "Unexpected declaration: #{name}"
129
+ raise "Unexpected declaration: #{name} (#{decl.class})"
129
130
  end
130
131
 
131
132
  env.each_extension(name).sort_by {|e| e.extension_name.to_s }.each do |extension|
@@ -87,5 +87,23 @@ module RBS
87
87
  new(path: string.split("::").map(&:to_sym), absolute: false)
88
88
  end
89
89
  end
90
+
91
+
92
+ def ascend
93
+ if block_given?
94
+ current = self
95
+
96
+ until current.empty?
97
+ yield current
98
+ current = current.parent
99
+ end
100
+
101
+ yield current
102
+
103
+ self
104
+ else
105
+ enum_for(:ascend)
106
+ end
107
+ end
90
108
  end
91
109
  end
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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: 0.2.0
4
+ version: 0.3.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-05-19 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler