Method: RBS::RecursiveAncestorError.check!

Defined in:
lib/rbs/errors.rb

.check!(self_ancestor, ancestors:, location:) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/rbs/errors.rb', line 85

def self.check!(self_ancestor, ancestors:, location:)
  case self_ancestor
  when Definition::Ancestor::Instance
    if ancestors.any? {|a| a.is_a?(Definition::Ancestor::Instance) && a.name == self_ancestor.name }
      raise new(ancestors: ancestors + [self_ancestor], location: location)
    end
  when Definition::Ancestor::Singleton
    if ancestors.include?(self_ancestor)
      raise new(ancestors: ancestors + [self_ancestor], location: location)
    end
  end
end