More type fills and shims - #1005
Conversation
Drop rubygems as rbs collection won't let us shim core
Pending types for this class being added to the RBS repo and then to the RBS version the user has loaded, this will allow Gemfiles to be typechecked.
| FileUtils.rm_rf path, secure: true | ||
| out.puts "Clearing pin cache in #{path}" unless out.nil? | ||
| else | ||
| out.puts "Pin cache file #{path} does not exist" unless out.nil? |
There was a problem hiding this comment.
Helpful when debugging the core RBS fills!
| end | ||
|
|
||
| FILLS_DIRECTORY = File.join(File.dirname(__FILE__), '..', '..', '..', 'rbs', 'fills') | ||
| FILLS_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'rbs', 'fills')) |
There was a problem hiding this comment.
Nicer to see an absolute path in log messages
| def loader | ||
| @loader ||= RBS::EnvironmentLoader.new(repository: RBS::Repository.new(no_stdlib: false)) | ||
| end | ||
|
|
There was a problem hiding this comment.
Whoops, we ended up with two identical methods here
| @@ -147,33 +147,33 @@ def virtual_pin? pin | |||
| # @return [Array<Problem>] | |||
| def method_param_type_problems_for pin | |||
| stack = api_map.get_method_stack(pin.namespace, pin.name, scope: pin.scope) | |||
There was a problem hiding this comment.
The type checker changes were needed to make the test in gemfile_spec work. It turns out that the type checker was checking parameter types using the result of Pin::Method#parameters, which for RBS-loaded types is always an empty array.
I took the opportunity to refactor the 'first_param_hash' method into 'param_details_from_stack', which takes both the method pins from the stack as well as the particular signature we're testing against, which I think is more compatible with how it is used.
| rooted: true, parameters_type: :list) | ||
| parameters.push Solargraph::Pin::Parameter.new(decl: :restarg, name: name, closure: pin, | ||
| source: :rbs, type_location: type_location, | ||
| return_type: rest_positional_type,) |
There was a problem hiding this comment.
I got into a bit of a yakshave here trying to get a test to pass, and found out that we don't preserve types for restargs from RBS.
| fill_loader.add(path: Pathname(FILLS_DIRECTORY)) | ||
| fill_conversions = Conversions.new(loader: fill_loader) | ||
| @pins.concat fill_conversions.pins | ||
|
|
There was a problem hiding this comment.
A single EnvironmentLoader complains if it's given the same symbol twice - which could happen if one of our temporary fills like Bundler::Dsl is eventually adopted upstream (see ruby/rbs#2599). We'll get around that by using a separate loader for the fills, and deal with combining the duplicate pins downstream.
| "Wrong argument type for Bundler::Dsl#source: source expected String, received Class<File>"].sort) | ||
| end | ||
|
|
||
| # @todo add rest arg support to type checker |
There was a problem hiding this comment.
I cut the yakshave off here so the changes to type checker weren't more aggressive than they already are.
…ph into gemfile_fixes
Should fix solargraph-rails spec failures
Pending types for this class being added to the RBS repo and then to the RBS version the user has loaded, this will allow Gemfiles to be typechecked.
There are also fixes for various missing types needed for typechecking Solargraph.
Depends on #1056