Handle type arguments appropriately
mame opened this issue · 0 comments
mame commented
Currently, TypeProf completely ignores Array[X]
of class Bar[X] < Foo[Array[X]]
.
class Foo[X]
def test_superclass: -> X
end
module M[X]
def test_module: -> X
end
class Bar[X] < Foo[Array[X]]
def initialize: (X) -> void
include M[Integer]
end
obj = Bar.new("str")
p obj #=> Foo[String]
p obj.test_superclass #=> expected: Array[String], actual: String
p obj.test_module #=> expected: Integer, actual: String
More practical example:
p({ a: 1 }.find { true }) #=> nil | untyped
because:
- A class Hash includes
Enumerable[[K, V], Hash[K, V]]
. Enumerable#find
returnsElem?
. In this case,Elem
==[K, V]
- However, TypeProf don't know that
Elem
==[K, V]
, so it replacesElem
withuntyped