Exception: RBS::DuplicatedMethodDefinitionError

Inherits:
DefinitionError show all
Includes:
DetailedMessageable
Defined in:
lib/rbs/errors.rb,
sig/errors.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DetailedMessageable

#detailed_message

Constructor Details

#initialize(type:, method_name:, members:) ⇒ DuplicatedMethodDefinitionError

Returns a new instance of DuplicatedMethodDefinitionError.

Parameters:

  • type: (ty)
  • method_name: (Symbol)
  • members: (Array[original])


258
259
260
261
262
263
264
265
266
267
268
# File 'lib/rbs/errors.rb', line 258

def initialize(type:, method_name:, members:)
  @type = type
  @method_name = method_name
  @members = members

  message = +"#{Location.to_string location}: #{qualified_method_name} has duplicated definitions"
  if members.size > 1
    message << " in #{other_locations.map { |loc| Location.to_string loc }.join(', ')}"
  end
  super message
end

Instance Attribute Details

#membersArray[original] (readonly)

Returns the value of attribute members.

Returns:

  • (Array[original])


256
257
258
# File 'lib/rbs/errors.rb', line 256

def members
  @members
end

#method_nameSymbol (readonly)

Returns the value of attribute method_name.

Returns:

  • (Symbol)


255
256
257
# File 'lib/rbs/errors.rb', line 255

def method_name
  @method_name
end

#typety (readonly)

Returns the value of attribute type.

Returns:

  • (ty)


254
255
256
# File 'lib/rbs/errors.rb', line 254

def type
  @type
end

Instance Method Details

#locationLocation[untyped, untyped]?

Returns:



283
284
285
# File 'lib/rbs/errors.rb', line 283

def location
  members[0].location
end

#other_locationsArray[Location[untyped, untyped]?]

Returns:



287
288
289
# File 'lib/rbs/errors.rb', line 287

def other_locations
  members.drop(1).map(&:location)
end

#qualified_method_nameString

Returns:

  • (String)


270
271
272
273
274
275
276
277
# File 'lib/rbs/errors.rb', line 270

def qualified_method_name
  case type
  when Types::ClassSingleton
    "#{type.name}.#{method_name}"
  else
    "#{type.name}##{method_name}"
  end
end

#type_nameTypeName

Returns:



279
280
281
# File 'lib/rbs/errors.rb', line 279

def type_name
  type.name
end