-
-
Notifications
You must be signed in to change notification settings - Fork 165
More type fills and shims #1005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
lib/solargraph/pin_cache.rb
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, we ended up with two identical methods here
| # @param pin [Pin::Method] | ||
| # @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
spec/convention/gemfile_spec.rb
Outdated
| "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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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