Skip to content

Commit d80265f

Browse files
authored
[regression] Restore 'Unresolved call' typecheck for stdlib objects (#849)
The 'Unresolved call to' typecheck suppresses warnings for calls against non-RBS-origin pins. However, the labeling assigning :rbs as the source of pins from conversions.rb was recently removed as part of an unrelated cleanup.
1 parent 767a5fc commit d80265f

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

lib/solargraph/rbs_map/conversions.rb

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def load_environment_to_pins(loader)
3838
environment = RBS::Environment.from_loader(loader).resolve_type_names
3939
cursor = pins.length
4040
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 }
4143
end
4244

4345
# @param decl [RBS::AST::Declarations::Base]

lib/solargraph/type_checker.rb

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def call_problems
268268
base = base.base
269269
end
270270
closest = found.typify(api_map) if found
271+
# @todo remove the internal_or_core? check at a higher-than-strict level
271272
if !found || found.is_a?(Pin::BaseVariable) || (closest.defined? && internal_or_core?(found))
272273
unless closest.generic? || ignored_pins.include?(found)
273274
result.push Problem.new(location, "Unresolved call to #{missing.links.last.word}")

spec/rbs_map/stdlib_map_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,12 @@
5656
expect(['Module<YAML>', 'Module<Psych>']).to include(return_type)
5757
end
5858
end
59+
60+
it 'pins are marked as coming from RBS parsing' do
61+
map = Solargraph::RbsMap::StdlibMap.load('yaml')
62+
store = Solargraph::ApiMap::Store.new(map.pins)
63+
constant_pins = store.get_constants('')
64+
pin = constant_pins.first
65+
expect(pin.source).to eq(:rbs)
66+
end
5967
end

0 commit comments

Comments
 (0)