Skip to content

Commit

Permalink
Fix an internal warning while typechecking (#761)
Browse files Browse the repository at this point in the history
* Fix an internal warning while typechecking

The current typechecking code logs:

```
WARNING: Pin #infer methods are deprecated. Use #typify or #probe
instead.
```

Move the infer() call to typify(), as we know are interested in
validating the declared type exists, not the inferred one.

* Fix logic to account for class/module aliases
  • Loading branch information
apiology authored Mar 1, 2025
1 parent 56be2ad commit 816a7ca
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/solargraph/type_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,16 @@ def method_return_type_problems_for pin
# @return [Boolean]
def resolved_constant? pin
return true if pin.typify(api_map).defined?
api_map.get_constants('', *pin.closure.gates)
.select { |p| p.name == pin.return_type.namespace }
.any? { |p| p.infer(api_map).defined? }
constant_pins = api_map.get_constants('', *pin.closure.gates)
.select { |p| p.name == pin.return_type.namespace }
return true if constant_pins.find { |p| p.typify(api_map).defined? }
# will need to probe when a constant name is assigned to a
# class/module (alias)
return true if constant_pins.find { |p| p.probe(api_map).defined? }
false
end

# @param pin [Pin::Base]
def virtual_pin? pin
pin.location && source_map.source.comment_at?(pin.location.range.ending)
end
Expand Down

0 comments on commit 816a7ca

Please sign in to comment.