"Method << does not exist on T.class_of(A)" use of def_delegators with sorbet

Viewed 1295

I've got a code that uses Singleton and Forwardable to delegate some methods to the internal Hash.

class A
  include Singleton

  extend T::Sig

  sig { returns(T::Hash[T.untyped, T.untyped]) }
  attr_reader :stars

  class << self
    extend Forwardable
    def_delegators :instance, :<<, :[], :stars
    def_delegators :stars, :length
  end

  sig { void }
  def initialize
    @stars = {}
  end

  sig { params(identifier: String).returns(B) }
  def [](identifier)
    @stars[identifier]
  end
end

I use A << B.new outside A class and when I run be srb tc I get Method << does not exist on T.class_of(A). Any suggestions or ideas how I can get rid of this warning?

0 Answers
Related