-
Notifications
You must be signed in to change notification settings - Fork 569
Closed
Labels
bugSomething isn't workingSomething isn't workingunconfirmedThis issue has not yet been confirmed by the Sorbet teamThis issue has not yet been confirmed by the Sorbet team
Description
Input
# typed: true
class A
extend T::Sig
extend T::Generic
include Enumerable
Elem = type_member(fixed: String)
sig { override.params(blk: T.proc.params(e: Elem).void).void }
def each(&blk)
T.unsafe(nil)
end
sig { returns(T::Array[Elem])}
def flatten
T.unsafe(nil)
end
end
def main
a = A.new
b = [A.new, A.new]
T.reveal_type(a.flatten)
T.reveal_type(b.flatten)
end
Observed output
Revealed type: T::Array[A]
Expected behavior
Revealed type: T::Array[String]
Flatten is called on subsequent objects of the collection. I'd expect that sorbet know flatten will call flatten
in the custom enumerable.
See convo on slack:
https://sorbet-ruby.slack.com/archives/CJL5B3CEN/p1583892614100500
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingunconfirmedThis issue has not yet been confirmed by the Sorbet teamThis issue has not yet been confirmed by the Sorbet team