solargraph 0.53.3 → 0.53.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5f84e528dd40d7638e36189ca6b4dceccdfd1722a07bd1c1f060bf0265aa815
4
- data.tar.gz: 39d6938ccabce6dda403c709711f6136472def5982222e73d89310eaeb906ee1
3
+ metadata.gz: 82af0b18d57296a8eef96680e60f131bad23268e4043d49407d197fc378dd3d2
4
+ data.tar.gz: 10c5622ac74f0feef06033ed0b851268c876a68581d846b2874fe61a29612acb
5
5
  SHA512:
6
- metadata.gz: cf06b94032becde9f26b7d5cedcecbc0fd7d6bde539a980c748328f11165f91398605e7ff49af502b83a70a4aa9b32406c5846cda96f5246d20c97d17220700b
7
- data.tar.gz: bdddccf5d52efd2a9be2b00ac473065ecca21d76646d59d247c5cb93b14de137ebfc16ec4ffbc3ed0d6e9de9f271e9763808775d6aa271496e6328bf70b443bf
6
+ metadata.gz: 1671b54ae2c314d5c566629706b6de94ca5de0902d1d56e7b96853a889d54b0caef084a5c416222f6fe9f4d40387ea3b56d34b6af917a36855ae902f0b8acf0d
7
+ data.tar.gz: e7b24e7c08164da0a0b60fc8f04281bfceef59e95470d3f3e78193b024d615da2ae62f94712222ffac722623f7de8207f7af29013bdad6787c63716556ecaf43
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.53.4 - March 30, 2025
2
+ - [regression] Restore 'Unresolved call' typecheck for stdlib objects (#849)
3
+ - Lazy dynamic rebinding (#851)
4
+ - Restore fill for Class#allocate (#848)
5
+ - [regression] Ensure YardMap gems have return type for Class<T>.new (#850)
6
+ - Create implicit .new pins in namespace method queries (#853)
7
+
1
8
  ## 0.53.3 - March 29, 2025
2
9
  - Remove redundant core fills (#824, #841)
3
10
  - Resolve self type in variable assignments (#839)
@@ -68,7 +68,6 @@ module Solargraph
68
68
  @store = Store.new(@@core_map.pins + @doc_map.pins + implicit.pins + pins)
69
69
  @unresolved_requires = @doc_map.unresolved_requires
70
70
  @missing_docs = [] # @todo Implement missing docs
71
- store.block_pins.each { |blk| blk.rebind(self) }
72
71
  self
73
72
  end
74
73
 
@@ -312,6 +311,26 @@ module Solargraph
312
311
  result.concat inner_get_methods('Kernel', :instance, visibility, deep, skip)
313
312
  else
314
313
  result.concat inner_get_methods(rooted_tag, scope, visibility, deep, skip)
314
+ unless %w[Class Class<Class>].include?(rooted_tag)
315
+ result.map! do |pin|
316
+ next pin unless pin.path == 'Class#new'
317
+ init_pin = get_method_stack(rooted_tag, 'initialize').first
318
+ next pin unless init_pin
319
+
320
+ type = ComplexType.try_parse(ComplexType.try_parse(rooted_tag).namespace)
321
+ Pin::Method.new(
322
+ name: 'new',
323
+ scope: :class,
324
+ location: init_pin.location,
325
+ parameters: init_pin.parameters,
326
+ signatures: init_pin.signatures.map { |sig| sig.proxy(type) },
327
+ return_type: type,
328
+ comments: init_pin.comments,
329
+ closure: init_pin.closure
330
+ # @todo Hack to force TypeChecker#internal_or_core?
331
+ ).tap { |pin| pin.source = :rbs }
332
+ end
333
+ end
315
334
  result.concat inner_get_methods('Kernel', :instance, [:public], deep, skip) if visibility.include?(:private)
316
335
  result.concat inner_get_methods('Module', scope, visibility, deep, skip)
317
336
  end
@@ -725,23 +744,22 @@ module Solargraph
725
744
  # @param visibility [Enumerable<Symbol>]
726
745
  # @return [Array<Pin::Base>]
727
746
  def resolve_method_aliases pins, visibility = [:public, :private, :protected]
728
- result = []
729
- pins.each do |pin|
747
+ pins.map do |pin|
730
748
  resolved = resolve_method_alias(pin)
731
- next if resolved.respond_to?(:visibility) && !visibility.include?(resolved.visibility)
732
- result.push resolved
733
- end
734
- result
749
+ next pin if resolved.respond_to?(:visibility) && !visibility.include?(resolved.visibility)
750
+ resolved
751
+ end.compact
735
752
  end
736
753
 
737
754
  # @param pin [Pin::MethodAlias, Pin::Base]
738
755
  # @return [Pin::Method]
739
756
  def resolve_method_alias pin
740
- return pin if !pin.is_a?(Pin::MethodAlias) || @method_alias_stack.include?(pin.path)
757
+ return pin unless pin.is_a?(Pin::MethodAlias)
758
+ return nil if @method_alias_stack.include?(pin.path)
741
759
  @method_alias_stack.push pin.path
742
760
  origin = get_method_stack(pin.full_context.tag, pin.original, scope: pin.scope).first
743
761
  @method_alias_stack.pop
744
- return pin if origin.nil?
762
+ return nil if origin.nil?
745
763
  args = {
746
764
  location: pin.location,
747
765
  closure: pin.closure,
@@ -493,6 +493,24 @@ module Solargraph
493
493
  end
494
494
  if params['data']['path']
495
495
  result.concat library.path_pins(params['data']['path'])
496
+ # @todo This exception is necessary because `Library#path_pins` does
497
+ # not perform a namespace method query, so the implicit `.new` pin
498
+ # might not exist.
499
+ if result.empty? && params['data']['path'] =~ /\.new$/
500
+ result.concat(library.path_pins(params['data']['path'].sub(/\.new$/, '#initialize')).map do |pin|
501
+ next pin unless pin.name == 'initialize'
502
+
503
+ Pin::Method.new(
504
+ name: 'new',
505
+ scope: :class,
506
+ location: pin.location,
507
+ parameters: pin.parameters,
508
+ return_type: ComplexType.try_parse(params['data']['path']),
509
+ comments: pin.comments,
510
+ closure: pin.closure
511
+ )
512
+ end)
513
+ end
496
514
  end
497
515
  # Selecting by both location and path can result in duplicate pins
498
516
  result.uniq { |p| [p.path, p.location] }
@@ -24,11 +24,11 @@ module Solargraph
24
24
  # @param api_map [ApiMap]
25
25
  # @return [void]
26
26
  def rebind api_map
27
- @binder ||= binder_or_nil(api_map)
27
+ @rebind ||= maybe_rebind(api_map)
28
28
  end
29
29
 
30
30
  def binder
31
- @binder || closure.binder
31
+ @rebind&.defined? ? @rebind : closure.binder
32
32
  end
33
33
 
34
34
  # @return [::Array<Parameter>]
@@ -44,17 +44,17 @@ module Solargraph
44
44
  private
45
45
 
46
46
  # @param api_map [ApiMap]
47
- # @return [ComplexType, nil]
48
- def binder_or_nil api_map
49
- return nil unless receiver
47
+ # @return [ComplexType]
48
+ def maybe_rebind api_map
49
+ return ComplexType::UNDEFINED unless receiver
50
50
 
51
51
  chain = Parser.chain(receiver, location.filename)
52
52
  locals = api_map.source_map(location.filename).locals_at(location)
53
53
  receiver_pin = chain.define(api_map, self, locals).first
54
- return nil unless receiver_pin
54
+ return ComplexType::UNDEFINED unless receiver_pin
55
55
 
56
56
  types = receiver_pin.docstring.tag(:yieldreceiver)&.types
57
- return nil unless types&.any?
57
+ return ComplexType::UNDEFINED unless types&.any?
58
58
 
59
59
  target = chain.base.infer(api_map, receiver_pin, locals)
60
60
  target = full_context unless target.defined?
@@ -135,7 +135,7 @@ module Solargraph
135
135
  result = []
136
136
  result.push generate_signature(parameters, top_type) if top_type.defined?
137
137
  result.concat(overloads.map { |meth| generate_signature(meth.parameters, meth.return_type) }) unless overloads.empty?
138
- result.push generate_signature(parameters, top_type) if result.empty?
138
+ result.push generate_signature(parameters, @return_type || ComplexType::UNDEFINED) if result.empty?
139
139
  result
140
140
  end
141
141
  end
@@ -38,6 +38,8 @@ module Solargraph
38
38
  environment = RBS::Environment.from_loader(loader).resolve_type_names
39
39
  cursor = pins.length
40
40
  environment.declarations.each { |decl| convert_decl_to_pin(decl, Solargraph::Pin::ROOT_PIN) }
41
+ added_pins = pins[cursor..-1]
42
+ added_pins.each { |pin| pin.source = :rbs }
41
43
  end
42
44
 
43
45
  # @param decl [RBS::AST::Declarations::Base]
@@ -29,7 +29,10 @@ module Solargraph
29
29
  Override.from_comment('Module#class_eval', '@yieldreceiver [Class<self>]'),
30
30
  Override.from_comment('Module#class_exec', '@yieldreceiver [Class<self>]'),
31
31
  Override.from_comment('Module#module_eval', '@yieldreceiver [Module<self>]'),
32
- Override.from_comment('Module#module_exec', '@yieldreceiver [Module<self>]')
32
+ Override.from_comment('Module#module_exec', '@yieldreceiver [Module<self>]'),
33
+ # RBS does not define Class with a generic, so all calls to
34
+ # generic() return an 'untyped'. We can do better:
35
+ Override.method_return('Class#allocate', 'self')
33
36
  ]
34
37
 
35
38
  # HACK: Add Errno exception classes
@@ -11,6 +11,7 @@ module Solargraph
11
11
  def initialize api_map, cursor
12
12
  @api_map = api_map
13
13
  @cursor = cursor
14
+ block.rebind(api_map) if block.is_a?(Pin::Block)
14
15
  end
15
16
 
16
17
  # @return [Array<Pin::Base>] Relevant pins for infering the type of the Cursor's position
@@ -268,6 +268,7 @@ module Solargraph
268
268
  base = base.base
269
269
  end
270
270
  closest = found.typify(api_map) if found
271
+ # @todo remove the internal_or_core? check at a higher-than-strict level
271
272
  if !found || found.is_a?(Pin::BaseVariable) || (closest.defined? && internal_or_core?(found))
272
273
  unless closest.generic? || ignored_pins.include?(found)
273
274
  result.push Problem.new(location, "Unresolved call to #{missing.links.last.word}")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.53.3'
4
+ VERSION = '0.53.4'
5
5
  end
@@ -19,17 +19,20 @@ module Solargraph
19
19
  gates: [code_object.namespace.to_s]
20
20
  )
21
21
  location = object_location(code_object, spec)
22
+ name ||= code_object.name.to_s
23
+ return_type = ComplexType::SELF if name == 'new'
22
24
  comments = code_object.docstring ? code_object.docstring.all.to_s : ''
23
25
  pin = Pin::Method.new(
24
26
  location: location,
25
27
  closure: closure,
26
- name: name || code_object.name.to_s,
28
+ name: name,
27
29
  comments: comments,
28
30
  scope: scope || code_object.scope,
29
31
  visibility: visibility || code_object.visibility,
30
32
  # @todo Might need to convert overloads to signatures
31
33
  parameters: [],
32
- explicit: code_object.is_explicit?
34
+ explicit: code_object.is_explicit?,
35
+ return_type: return_type
33
36
  )
34
37
  pin.parameters.concat get_parameters(code_object, location, comments, pin)
35
38
  pin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.53.3
4
+ version: 0.53.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-29 00:00:00.000000000 Z
11
+ date: 2025-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport