Exception: RBS::DuplicatedInterfaceMethodDefinitionError

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

Overview

An interface mixin causes a duplication of a method definition

interface _Foo1
  def foo: () -> void
end

interface _Foo2
  def foo: () -> void
end

class Foo
  include _Foo1
  include _Foo2    # <= The error will be reported here (or the line of _Foo1)
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DetailedMessageable

#detailed_message

Constructor Details

#initialize(type:, method_name:, member:) ⇒ DuplicatedInterfaceMethodDefinitionError

Returns a new instance of DuplicatedInterfaceMethodDefinitionError.

Parameters:

  • type: (ty)
  • method_name: (Symbol)
  • member: (mixin_member)


299
300
301
302
303
304
305
# File 'lib/rbs/errors.rb', line 299

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

  super "#{member.location}: Duplicated method definition: #{qualified_method_name}"
end

Instance Attribute Details

#membermixin_member (readonly)

Returns the value of attribute member.

Returns:

  • (mixin_member)


297
298
299
# File 'lib/rbs/errors.rb', line 297

def member
  @member
end

#method_nameSymbol (readonly)

Returns the value of attribute method_name.

Returns:

  • (Symbol)


296
297
298
# File 'lib/rbs/errors.rb', line 296

def method_name
  @method_name
end

#typety (readonly)

Returns the value of attribute type.

Returns:

  • (ty)


295
296
297
# File 'lib/rbs/errors.rb', line 295

def type
  @type
end

Instance Method Details

#locationAST::Members::Mixin::loc?

Returns:

  • (AST::Members::Mixin::loc, nil)


307
308
309
# File 'lib/rbs/errors.rb', line 307

def location
  member.location
end

#qualified_method_nameString

Returns:

  • (String)


311
312
313
314
315
316
317
318
# File 'lib/rbs/errors.rb', line 311

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

#type_nameTypeName

Returns:



320
321
322
# File 'lib/rbs/errors.rb', line 320

def type_name
  type.name
end