I'm seeing some unexpected behaviour setting up RBS types on an existing Ruby project. A minimal example:
# lib/a.rb
class A
def self.foo
new
end
end
class B < A
def self.foo
super
end
end
puts A.foo.inspect
puts B.foo.inspect
Output
#<A:0x000055f7cfb03908>
#<B:0x000055f7cfb037f0>
Signature
# lib/a.rbs
class A
def self.foo: () -> A
end
class B < A
def self.foo: () -> B
end
but the steep type-checker gives me errors
lib/a.rb:8:11: [error] Cannot allow method body have type `::A` because declared as type `::B`
│ ::A <: ::B
│ ::Object <: ::B
│ ::BasicObject <: ::B
│
│ Diagnostic ID: Ruby::MethodBodyTypeMismatch
│
└ def self.foo
~~~
Is this an issue with steep or (more likely) my understanding of the Ruby typing syntax?