ruby/typeprof

Instance variables in subclasses sometimes are defined incorrectly

wagenet opened this issue · 2 comments

In my specific case, it is overwriting the parent type with something overly specific:

class Base
  @warnings_suppressed: bool
end

class Subclass < Base
  @warnings_suppressed: bot
end

Rough code:

class Base
  def initialize
    @warnings_suppressed = false
  end

  def suppress_warnings!
    tap { @warnings_suppressed = true }
  end

  def warn(message, event = nil)
    return if @warnings_suppressed
    puts message
  end
end

class Subclass < Base
  def do_stuff
    warn("Something went wrong")
  end
end
mame commented

Thank you! Is this fixed by your pull request #94?

Yes, this should be fixed now.