Exception: RBS::DuplicatedMethodDefinitionError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rbs/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(decl:, name:, location:) ⇒ DuplicatedMethodDefinitionError

Returns a new instance of DuplicatedMethodDefinitionError.



200
201
202
203
204
205
206
207
208
209
# File 'lib/rbs/errors.rb', line 200

def initialize(decl:, name:, location:)
  decl_str = case decl
             when AST::Declarations::Interface, AST::Declarations::Class, AST::Declarations::Module
               decl.name.to_s
             when AST::Declarations::Extension
               "#{decl.name} (#{decl.extension_name})"
             end

  super "#{Location.to_string location}: #{decl_str} has duplicated method definition: #{name}"
end

Instance Attribute Details

#declObject (readonly)

Returns the value of attribute decl.



197
198
199
# File 'lib/rbs/errors.rb', line 197

def decl
  @decl
end

#locationObject (readonly)

Returns the value of attribute location.



198
199
200
# File 'lib/rbs/errors.rb', line 198

def location
  @location
end

Class Method Details

.check!(decl:, methods:, name:, location:) ⇒ Object



211
212
213
214
215
# File 'lib/rbs/errors.rb', line 211

def self.check!(decl:, methods:, name:, location:)
  if methods.key?(name)
    raise new(decl: decl, name: name, location: location)
  end
end