Closed
Description
The following code:
module MyModule
class Bar
def initialize
# empty
end
end
class Baz
# empty
end
class Foo1 < Bar
class << self
# This is an error
#
# @return [Foo1]
def foo
new
end
end
end
class Foo2 < Baz
class << self
# But this is not an error, and the only difference is whether the parent
# class has an `initialize` method
#
# @return [Foo2]
def foo
new
end
end
end
end
Gives the following error:
% solargraph typecheck --level typed tmp.rb
tmp.rb:17 - Declared return type MyModule::Foo1 does not match inferred type Foo1 for MyModule::Foo1.foo
1 problem found.
Changing line 17 to @return [MyModule::Foo1]
resolves the issue, but it seems like that shouldn't be necessary or it should be required for line 28 (@return [Foo2]
) as well.
Metadata
Metadata
Assignees
Labels
No labels