Skip to content

Commit

Permalink
ApiMap#get_methods always includes Kernel methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Dec 24, 2019
1 parent ee924af commit d9e7438
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/solargraph/api_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def get_methods fqns, scope: :instance, visibility: [:public], deep: true
result.concat inner_get_methods('Kernel', :instance, visibility, deep, skip)
else
result.concat inner_get_methods(fqns, scope, visibility, deep, skip)
result.concat get_methods('Kernel', scope: :instance, visibility: [:public], deep: true) if deep && fqns != 'Kernel'
end
resolved = resolve_method_aliases(result, visibility)
cache.set_methods(fqns, scope, visibility, deep, resolved)
Expand Down
11 changes: 11 additions & 0 deletions spec/type_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -486,4 +486,15 @@ def bar bool
))
expect(checker.strict_type_problems).to be_one
end

it 'resolves Kernel methods in instance scopes' do
checker = Solargraph::TypeChecker.load_string(%(
class Foo
def bar
raise 'oops'
end
end
))
expect(checker.strict_type_problems).to be_empty
end
end

0 comments on commit d9e7438

Please sign in to comment.