Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/solargraph/pin/method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def combine_with(other, attrs = {})
end
new_attrs = {
visibility: combine_visibility(other),
# @sg-ignore https://github.com/castwide/solargraph/pull/1050
explicit: explicit? || other.explicit?,
block: combine_blocks(other),
node: choose_node(other, :node),
Expand Down
4 changes: 2 additions & 2 deletions lib/solargraph/source/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ def infer_from_definitions pins, context, api_map, locals
else
ComplexType.new(types)
end
if context.nil? || context.return_type.undefined?
if context.nil? || context.context.undefined?
# up to downstream to resolve self type
return type
end

type.self_to_type(context.return_type)
type.self_to_type(context.context)
end

# @param type [ComplexType]
Expand Down
50 changes: 50 additions & 0 deletions spec/type_checker/levels/alpha_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

describe Solargraph::TypeChecker do
context 'when at alpha level' do
def type_checker code
Solargraph::TypeChecker.load_string(code, 'test.rb', :alpha)
end

it 'resolves self correctly in arguments' do
checker = type_checker(%(
class Foo
# @param other [self]
#
# @return [String]
def bar other
other.bing
end

# @return [String]
def bing
'bing'
end
end
))

expect(checker.problems.map(&:message)).to eq([])
end

it 'resolves self correctly in arguments (second case)' do
checker = type_checker(%(
class Blah
# @return [String]
attr_reader :filename

# @param filename [String]
def initialize filename
@filename = filename
end

# @param location [self]
def contain? location
filename == location.filename
end
end
))

expect(checker.problems.map(&:message)).to eq([])
end
end
end
Loading